Example One:
Front desk
Copy Code code 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 ">
<title> Untitled Page </title>
<body>
<form id= "Form1" runat= "Server" >
<div id= "Div1" >
<asp:button id= "Button1" runat= "Server" text= "button" onclick= "Button1_Click"/>
</div>
</form>
</body>
Background
Copy Code code as follows:
public partial class _default:system.web.ui.page
{
protected void Page_Load (object sender, EventArgs e)
{
}
protected void Button1_Click (object sender, EventArgs e)
{
String name = "Tree";
Server.Transfer ("ajax.aspx?id=1&name=" +name);
Changecontrols ();
}
/************controls Property ************
* this. Controls includes all the controls.
* System.Web.UI.LiteralControl
System.Web.UI.HtmlControls.HtmlHead
System.Web.UI.LiteralControl
System.Web.UI.HtmlControls.HtmlForm
System.Web.UI.LiteralControl
* For <div id= "Div1" > plus runat attribute, form.controls is not found in Button1
*/
private void Changecontrols ()
{
foreach (System.Web.UI.Control control in this. Form.controls)
{
If (Control is Button)
{
Button btn = (button) control;
Btn. Text = "Hello";
}
}
foreach (Control-this. Controls)
{
Response.Write (Control. ToString () + "<br/>");
}
}
}