Methods for calling the content page on the ASP. NET master page and methods on the. ASPX page of the Web user control

Source: Internet
Author: User

Method on the. ASPX page called by the Web user control

Today, a Web user control contains two repeater s, one for displaying data and one for paging. I have rewritten the binding event to bind data. However, I used the paging control to control the repeater data, so I used the binding event to call the page by clicking the paging control to re-obtain the data of different pages. I found the following method on the Internet. In the itemcommand event of the paging control
Protected void repctrl_itemcommand (Object source, repeatercommandeventargs E)
{
Int32 COUNT = count;
Int32 pagesize = pagesize;
Int32 pageindex = pageindex;
Int32 Pi = count % pagesize = 0? Count/pagesize: Count/pagesize + 1;

If (E. commandname = "page ")
{
If (E. commandargument. tostring () = "Next ")
{
// The paging part is omitted.
}
}
System. Web. UI. Page P = This. page;
// Use the Reflection Method to dynamically call the parent page
Type pagetype = P. GetType ();
Methodinfo MI = pagetype. getmethod ("boundlist ");
Mi. Invoke (p, new object [] {pageindex, pagesize, sortfield, ordertype}); // new object [] {parameter to be passed
}
The following is the Web. aspx PAGE method:

Public void boundlist (INT pageindex, int pagesize, string sortfiled, short ordertype)
{// Write the correspondingProgram}
In this way, you can call it.

How to call the content page on the ASP. NET master page

First, define the delegate (delegate) on the master page ):
Namespace notsee. Web. Manage
{
Public partial class SYS: system. Web. UI. masterpage
{
Public Delegate void elementselectedchangehandler ();
// Instantiate the delegate, which is actually an attribute
Public elementselectedchangehandler elementselectedchange {private get; set ;}
Protected void page_load (Object sender, eventargs E)
{// Notsee.info Technical Exchange
}
// Buttons in the master
Protected void btnsearch_click (Object sender, eventargs E)
{
If (elementselectedchange! = NULL)
{
Elementselectedchange ();
}
}
}
}

For example, on the notsee. aspx content page, we need to specify a method that matches the delegate signature in the notsee. ASPX page:
Namespace WMS. Web. Manage
{
Public partial class notsee: system. Web. UI. Page
{
Master. elementselectedchange = This. elementselectedchange;
Protected void page_load (Object sender, eventargs E)
{// Notsee.info Technical Exchange
}
Void elementselectedchange ()
{
// Your solution
}
}
}
From http://www.notsee.info/tech/tech.xml

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.