PrM-pageloaded event

Source: Internet
Author: User
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 ();
}

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.