![]() |
|
|
|
#1 |
|
Hello All,
I created a new ASP.NET web application and printed out the number of controls in the page Response.Write(this.Page.Controls.Count.ToString() ); It shows a count of 3 even though I did not add any controls to the page. Could anyone explain why ? Thanks ! Niranjan |
|
|
|
|
#2 |
|
Posts: n/a
|
Have you tried walking through your code? If you add your
page object to the watch window, you can open up the Page.Controls collection and look at which controls are inside. The Form is actually a control inside the page, so even if you haven't added any controls to the page, the Form will still be there. >-----Original Message----- >Hello All, > >I created a new ASP.NET web application and printed out the number of >controls in the page > >Response.Write(this.Page.Controls.Count.ToString( )); > >It shows a count of 3 even though I did not add any controls to the >page. Could anyone explain why ? > >Thanks ! >. > Becky |
|
|
|
#3 |
|
Posts: n/a
|
Set a breakpoint in the Page load sub. Use the IDE to
explore the properties of the Page.Controls object. >-----Original Message----- >Hello All, > >I created a new ASP.NET web application and printed out the number of >controls in the page > >Response.Write(this.Page.Controls.Count.ToString( )); > >It shows a count of 3 even though I did not add any controls to the >page. Could anyone explain why ? > >Thanks ! >. > |
|
|
|
#4 |
|
Posts: n/a
|
i think you should try the following code to get the
Controls List contained in your WebPage. __________________________________________________ _______ int iTotalControlCount = 0; System.Text.StringBuilder sbControls = new System.Text.StringBuilder(""); private void Page_Load(object sender, System.EventArgs e) { TotalControlCount(this); Response.Write("Total Controls Count = " + iTotalControlCount.ToString()); Response.Write(sbControls.ToString()); } private void TotalControlCount(Control ctl) { iTotalControlCount++; sbControls.Append("<br>" + ctl.ID + " -- " + ctl.GetType().ToString()); if(ctl.HasControls()) { foreach(Control eachCtl in this.Controls) { iTotalControlCount++; sbControls.Append("<br>"); sbControls.Append(eachCtl.ID + " -- " + eachCtl.GetType().ToString()); ChildControlCount(eachCtl); } } } private void ChildControlCount(Control ctl) { if(ctl.HasControls()) { foreach(Control eachCtl in ctl.Controls) { iTotalControlCount++; sbControls.Append("<br>"); sbControls.Append(eachCtl.ID + " -- " + eachCtl.GetType().ToString()); ChildControlCount(eachCtl); } } } __________________________________________________ _______ >-----Original Message----- >Hello All, > >I created a new ASP.NET web application and printed out the number of >controls in the page > >Response.Write(this.Page.Controls.Count.ToString( )); > >It shows a count of 3 even though I did not add any controls to the >page. Could anyone explain why ? > >Thanks ! >. > Satish R. Katika |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Asp.Net Custom Controls & Safari Compatibility | Osiris | General Help Related Topics | 0 | 06-01-2009 08:03 PM |
| ASP.NET Server controls on cross post back | Fachmann | Software | 1 | 12-18-2007 08:48 PM |
| ASP.Net Project Structure Question | koraykazgan | Software | 0 | 08-10-2007 08:23 AM |
| Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good | God | DVD Video | 3 | 04-25-2005 04:19 PM |
| Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good | Filthy Mcnasty | DVD Video | 0 | 04-25-2005 04:29 AM |