Controls that traverse the page of the Application Master page in ASP.

Source: Internet
Author: User
Tags html form

You should figure out what the controls are on the first floor.

The control we are looking for is generally on the fourth floor site1_master---contentplaceholder---HtmlForm---CheckBox

First floor is site1_master, master

The second floor is ContentPlaceHolder, which is the ' pit ' of the master version,

The third layer is HtmlForm, which is the HTML form,

The fourth layer is the child control.

So you have to iterate.

The following example uses a multi-layered traversal to find a checkbox in a page and lists each layer name

String S= "";

for (int i = 0; i < Page.Controls.Count; i++) all controls in//site1_master
{
foreach (Control conn in page.controls[i]. Controls)//traversing in Site1_master, looking for ContentPlaceHolder
{
foreach (Control con in Conn. Controls)//Traversal in ContentPlaceHolder, looking for HtmlForm
{
foreach (Control C in con. Controls)//traversing in HtmlForm, looking for a checkbox
{
if (C.gettype (). Name.equals ("checkbox"))
{
S=conn. GetType (). Name + "---" + con. GetType (). Name + "---" + c.gettype (). Name;
}

}
}

}
}

Novice, there are errors please correct me, thank you!

Controls that traverse the page of the Application Master page in ASP.

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.