PrM-pageloaded event
• Parameter type: pageloadedeventargs
-Dataitems attribute: obtains data items registered on the server.
-Panelscreated property: obtains the newly created updatepanel.
-Panelsupdated attribute: obtains the updated updatepanel.
• Common Operations:
-(CAN) obtain data items registered on the server
-(Capable) execute the script registered on the server.
Add local content <% @ Page Language = " C # " Masterpagefile = " ~ /Site. Master " Autoeventwireup = " True " Codefile = " 4_incrementalcontent.aspx.cs " Inherits = " _ 4_incrementalcontent " Title = " Incrementalcontent " Enableviewstate = " False " %>
< ASP: Content ID = " Content1 " Contentplaceholderid = " Contentplaceholder1 " Runat = " Server " >
< Strong > Comment: </ Strong > < BR /> < BR />
< Div ID = " Commentcontainer " >
< ASP: updatepanel ID = " Updatepanel1 " Runat = " Server " >
< Contenttemplate >
< ASP: repeater ID = " Repeater1 " Runat = " Server " >
< Itemtemplate >
<% # (Container. dataitem As Comment). Content %> < BR />
< I > <% # (Container. dataitem As Comment). Time %> </ I >
< HR />
</ Itemtemplate >
</ ASP: Repeater >
</ Contenttemplate >
< Triggers >
< ASP: asyncpostbacktrigger controlid = " Button1 " />
</ Triggers >
</ ASP: updatepanel >
</ Div >
< BR />
< ASP: textbox ID = " Textbox1 " Runat = " Server " > </ ASP: textbox > < BR />
< ASP: button ID = " Button1 " Runat = " Server " Text = " Add Comment " Onclick = " Button#click " />
< Script Language = " Javascript " Type = " Text/JavaScript " >
SYS. webforms. pagerequestmanager. getinstance (). add_pageloaded (
Function (sender, E)
{
VaR upid = " <% = This. updatepanel1.clientid %> " ;
VaR refreshedpanels = E. get_panelsupdated ();
For (VAR I = 0 ; I < Refreshedpanels. length; I ++ )
{
If (Refreshedpanels [I]. ID = Upid)
{
Refreshedpanels [I]. ID = Upid + Math. Floor ( 9999 * Math. Random ());
VaR Div = Document. createelement ( " Div " );
Div. ID = Upid;
$ Get ( " Commentcontainer " ). Appendchild (DIV );
Return ;
}
}
});
</ Script >
</ ASP: Content >
CSPrivate StaticList<Comment>Comments;
Protected Void Page_load ( Object Sender, eventargs E)
{
If ( ! This . Ispostback)
{
// All comments are cleared when the page is opened for the first time.
// This method is used only in this example.
Comments = New List < Comment > ();
This . Bindcomments ();
}
}
Private VoidBindcomments ()
{
This. Repeater1.datasource=Comments;
This. Repeater1.databind ();
}
Protected Void Button#click ( Object Sender, eventargs E)
{
Comment comment = New Comment ();
Comment. Content = This . Textbox1.text;
Comment. Time = Datetime. now;
// comments. add (comment);
This . repeater1.datasource = New comment [] {comment};
// This. bindcomments ();
This . repeater1.databind ();
}