Ajax Control Learning

Source: Internet
Author: User
123 I was learning an instance above. I wanted to learn and write down some things, but I found that it was better to write the records by myself. So I have time to record some things I learned during the summer vacation.
Let's take a look at Ajax's local refresh.

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> untitled page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Asp: scriptmanager id = "scriptmanager1" runat = "server"/>
<Div>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Contenttemplate>
<Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click"/>
<Asp: Label id = "label1" runat = "server" text = "label"> </ASP: Label>
</Contenttemplate>
</ASP: updatepanel>
<Asp: Label id = "label2" runat = "server" text = "label"> </ASP: Label>
</Div>
</Form>
</Body>
</Html>
We put a label and a button control in updatepanel, and a label outside.
Background Code :

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Label1.text = system. datetime. Now. tostring ();
Label2.text = system. datetime. Now. tostring ();
}
Protected void button#click (Object sender, eventargs E)
{
Label1.text = system. datetime. Now. tostring ();
Label2.text = system. datetime. Now. tostring ();
}
}

When you click the button, only the big label time is changed.

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.