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.