Ajax implements Static Page refreshing with rotating images loaded

Source: Internet
Author: User

Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head id = "Head1" runat = "server">
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Link href = "/Style/NiuLan.css" rel = "stylesheet" type = "text/css"/>
<Title> </title>
<Script type = "text/javascript"> // when the page is refreshed, the original display data on the page is not hidden. This is a hidden function.
// Obtain the PageRequestManager object. Each Asp.net Ajax page will have a unique object on the right to handle all Async-Postback requirements.
Var prm = Sys. webForms. pageRequestManager. getInstance (); // the newly added event is processed to the initializeRequest event of PageRequestManager. When Async-Postback occurs, this event is triggered and our InitRequest function is run.
Prm. add_initializeRequest (InitRequest );
// Add an event to process the endRequest event of PageRequestManager. When Async-Postback is complete, this event is triggered and our EndRequest function is run.
Prm. add_endRequest (EndRequest); function InitRequest (sender, args ){
// Display the UpdateProgress1 Control
Document. getElementById ('detail'). style. display = "none ";
}
Function EndRequest (sender, args ){
// Hide the UpdateProgress1 Control
Document. getElementById ('detail'). style. display = "block ";
}
// Cancels the Async-Postback action.
Function CancelClick (){
// When it is in the Async-Postback action, the get_isInAsyncPostBack function returns true. Then, the Async-Postback action is canceled when the abortPostBack function is called.
If (prm. get_isInAsyncPostBack ()){
Prm. abortPostBack ();
}
}
</Script>
</Head>
<Body>
<Form id = "Form1" runat = "server">
// Use ScriptManager in Ajax Extensitons
<Asp: ScriptManager runat = "server">
</Asp: ScriptManager>
// Usage example
<Asp: UpdatePanel ID = "UpdatePanel1" runat = "server">
<ContentTemplate>
// Put the code
<Div id = "detail"> <asp: ImageButton ID = "ibtnFBSJ" runat = "server" ImageUrl = "/images/ershoufang/bs/fbsj.gif"
OnClick = "ibtnFBSJ_Click"/>
</Div>
// When the page is refreshed statically, The UpdateProgress will be called, but this background also requires code. See the following:
<Asp: UpdateProgress ID = "UpdateProgress1" runat = "server" AssociatedUpdatePanelID = "UpdatePanel1">
<ProgressTemplate>
<Div style = "text-align: center">

</Div>
</ProgressTemplate>
</Asp: UpdateProgress>
</ContentTemplate>
</Asp: UpdatePanel>
</Form>
</Body>
</Html>
Background
Protected void ibtnFBSJ_Click (object sender, ImageClickEventArgs e)
{
System. Threading. Thread. Sleep (2000 );
DrpSortOrder. SelectedValue = (int) ErShouFangJiChuZuFang. order. sort by release time). ToString ();
PopulateDetails ();
}
// In this way, the page can be refreshed statically, with images rotated during loading. The user experience will be very good as follows:

 
Of course, you can also use jquery or ajax to write and dynamically load tables.

Related Article

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.