A small example of Ajax application in ASP. NET

Source: Internet
Author: User

Recently, many people on the CSDN Forum asked about ajax in ASP. NET applications, and problems are constantly being mentioned. Many experts have also published many professional technical documents. I am also ugly today, and I will give you a simple and easy-to-understand example...
First, we will introduce several professional terms:
Ajax: AJAX is "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML). AJAX is not a acronym, but a term created by Jesse James Gaiiett, this is a web development technology used to create interactive web applications.
Common Ajax controls in Visual studio 2008:
ScriptManager control: Manages Ajax server controls in pages and is the core control of Ajax.
UpdatePanel control: Implements asynchronous update of containers so that server controls that cannot be asynchronously updated implement Ajax functions.
Timer control: Timer is a Timer, but it is not only difficult but also resource-consuming in ASP.net.
After the component is introduced, paste the following code:
Front-end Html code and server-side controls
Html code
<Form id = "form1" runat = "server">

<Asp: ScriptManager ID = "ScriptManager1" runat = "server">
</Asp: ScriptManager>
<Asp: Timer ID = "Timer1" runat = "server" ontick = "Timer1_Tick">
</Asp: Timer>
<Div>
<Asp: UpdatePanel ID = "UpdatePanel1" runat = "server">
<Triggers>
<Asp: AsyncPostBackTrigger ControlID = "Timer1" EventName = "Tick"/>
</Triggers>
<ContentTemplate>
<Asp: Label ID = "Label1" runat = "server" Text = "Label"> </asp: Label>
</ContentTemplate>
</Asp: UpdatePanel>
</Div>
</Form>
Background C # code
Csharp code
Protected void Page_Load (object sender, EventArgs e)
{
Databing ();
}
Protected void timereffectick (object sender, EventArgs e)
{
Timer1.integer = 5000;
}
Private void databing ()
{
Label1.Text = DateTime. Now. ToString ();
}

To dynamically update pages within 5 seconds, it is not necessarily possible to achieve this at the beginning of the operation because of the high overhead.
Timer1.integer = 5000
The value here is the number of milliseconds, 1 second = 1000 milliseconds

 

This article is from weiqiao"

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.