Use updateprogress of ajax1.0

Source: Internet
Author: User

<% @ 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 void button_click (Object sender, eventargs E)
{
System. Threading. thread. Sleep (3000 );
}
</SCRIPT>

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head id = "head1" runat = "server">
<Title> updateprogress example </title>
<Style type = "text/CSS">
# Updatepanel1, # updatepanel2, # updateprogress1 {
Border-Right: Gray 1px solid; border-top: Gray 1px solid;
Border-left: Gray 1px solid; border-bottom: Gray 1px solid;
}
# Updatepanel1, # updatepanel2 {
Width: 200px; Height: 200px; position: relative;
Float: Left; margin-left: 10px; margin-top: 10px;
}
# Updateprogress1 {
Width: 400px; Background-color: # ffc080;
Bottom: 0%; left: 0px; position: absolute;
}
</Style>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: scriptmanager id = "scriptmanager1" runat = "server"/>
<SCRIPT type = "text/JavaScript">
VaR PRM = SYS. webforms. pagerequestmanager. getinstance ();
PRM. add_initializerequest (initializerequest );
PRM. add_endrequest (endrequest );
VaR postbackelement;
Function initializerequest (sender, argS ){
If (PRM. get_isinasyncpostback ())
{
Args. set_cancel (true );
}
Postbackelement = args. get_postbackelement ();
If (postbackelement. ID = 'buttontrigger ')
{
$ Get ('updateprogress1'). style. Display = "Block ";
}
}
Function endrequest (sender, argS ){
If (postbackelement. ID = 'buttontrigger ')
{
$ Get ('updateprogress1'). style. Display = "NONE ";
}
}
Function abortpostback (){
If (PRM. get_isinasyncpostback ()){
PRM. abortpostback ();
}
}
</SCRIPT>
<Asp: button id = "buttontrigger" runat = "server" text = "Refresh Panel 1" onclick = "button_click"/>
<Asp: updatepanel id = "updatepanel1" updatemode = "Conditional" runat = "server">
<Contenttemplate>
<% = Datetime. Now. tostring () %> <br/>
The trigger for this Panel
Causes the updateprogress to be displayed
Even though the updateprogress is associated
With panel 2.
<Br/>
</Contenttemplate>
<Triggers>
<Asp: asyncpostbacktrigger controlid = "buttontrigger"/>
</Triggers>
</ASP: updatepanel>
<Asp: updatepanel id = "updatepanel2" updatemode = "Conditional" runat = "server">
<Contenttemplate>
<% = Datetime. Now. tostring () %> <br/>
<Asp: button id = "button2" runat = "server" text = "Refresh panel" onclick = "button_click"/>
</Contenttemplate>
</ASP: updatepanel>
<Asp: updateprogress id = "updateprogress1" runat = "server" associatedupdatepanelid = "updatepanel2">
<Progresstemplate>
Update in progress...
<Input type = "button" value = "stop" onclick = "abortpostback ()"/>
</Progresstemplate>
</ASP: updateprogress>
</Div>
</Form>
</Body>
</Html>

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.