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