<% @ Page Language = "C #" %>
<! Doctype HTML public"-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT runat ="Server">
Protected VoidProcessclick_handler (Object sender, eventargs E)
{
System. Threading. thread. Sleep (2000 );
}
</SCRIPT>
<HTML>
<Head id ="Head1" Runat = "Server" >
<Title> pagerequestmanager beginrequest example </title>
<Style type = "Text/CSS" >
Body {
Font-family: tahoma;
}
Div. alertstyle
{
Background-color: # ffc080;
Top: 95%;
Left: 1%;
Height: 20px;
Width: 270px;
Position: absolute;
Visibility: hidden;
}
</Style>
</Head>
<Body>
<Form ID = "Form1" Runat = "Server" >
<Div>
<Asp: scriptmanager id = "Scriptmanager1" Runat = "Server" />
<SCRIPT type = "Text/JavaScript" Language = "JavaScript" >
SYS. webforms. pagerequestmanager. getinstance (). add_beginrequest (beginrequesthandler );
SYS. webforms. pagerequestmanager. getinstance (). add_endrequest (endrequesthandler );
Function beginrequesthandler (sender, argS)
{
VaR ELEM = args. get_postbackelement ();
Activatealertdiv ('visible ', 'alertdiv', ELEM. Value + 'processing ...');
}
Function endrequesthandler (sender, argS)
{
Activatealertdiv ('hiddd', 'alertdiv ','');
}
Function activatealertdiv (visstring, ELEM, MSG)
{
VaR adiv = $ Get (ELEM );
Adiv. style. Visibility = visstring;
Adiv. innerhtml = MSG;
}
</SCRIPT>
<Asp: updatepanel id = "Updatepanel1" Updatemode = "Conditional" Runat = "Server" >
<Contenttemplate>
<Asp: Panel id = "Panel1" Runat ="Server" Groupingtext = "Update panel" >
Last update:
<% = Datetime. Now. tostring () %>.
<Br/>
<Asp: button runat ="Server" Id = "Button1" TEXT = "Process 1" Onclick = "Processclick_handler" />
<Asp: button runat = "Server" Id = "Button2" TEXT = "Process 2" Onclick = "Processclick_handler" />
</ASP: Panel>
</Contenttemplate>
</ASP: updatepanel>
<Div id = "Alertdiv" Class = "Alertstyle" >
</Div>
</Div>
</Form>
</Body>
</Html>