Instance 1:
Front-end
CopyCode The Code is as follows: <% @ page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>
<! 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 runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div id = "div1">
<Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click"/>
</Div>
</Form>
</Body>
</Html>
BackgroundCopy codeThe Code is as follows: public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
}< br> protected void button#click (Object sender, eventargs e)
{< br> string name = "Tree";
// server. transfer ("Ajax. aspx? Id = 1 & name = "+ name);
changecontrols ();
}< br>/************** controls attributes *************
* This. controls includes all controls.
* system. web. UI. literalcontrol
system. web. UI. htmlcontrols. htmlhead
system. web. UI. literalcontrol
system. web. UI. htmlcontrols. htmlform
system. web. UI. literalcontrol
* adds the runat attribute to
, then form. button1
*/
private void changecontrols ()
{< br> foreach (system. web. UI. control in this. form. controls)
{< br> If (control is button)
{< br> button BTN = (button) control;
BTN. TEXT = "hello";
}< BR >}< br> foreach (Control in this. controls)
{< br> response. write (control. tostring () + "
");
}< BR >}