CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 7/25/2007 8:52:43 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 41 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
armst13
Asp.Net User
Looping Through Controls in Master Pages7/25/2007 8:52:43 PM

0

Is there anyway to find the "main control" on a form and loop through them all, when using master pages, without having to do a massive nested loop such as the following:

//foreach(Control c1 in Page.Controls)

//{

// if(c1.GetType().ToString() == "ASP.site_master")

// {

// foreach(Control c2 in c1.Controls)

// {

// if (c2.GetType().ToString() == "System.Web.UI.HtmlControls.HtmlForm")

// {

// foreach (Control c3 in c2.Controls)

// {

// if (c3.GetType().ToString() == "System.Web.UI.WebControls.ContentPlaceHolder")

// {

// foreach (Control c4 in c3.Controls)

I am trying to do something like the following, using various methods, but all of these have failed.  It is more clean and would seem to be more efficient than nested if statements.  But these always come back "NULL" everytime.  Or do I have to do the nested method.  It would seem there should be a way, but I can't find a way. 

Control c7 = this.FindControl("ASP.site_master"); Control c5 = Page.FindControl("System.Web.UI.HtmlControls.HtmlForm");

Control c6 = this.FindControl("ContentPlaceHolder1");

Thanks

Andy

mihirpathak
Asp.Net User
Re: Looping Through Controls in Master Pages7/25/2007 9:24:28 PM

0

Hi,

 If you have Label inside your master control you can access it:

Label lbl = (Label)Master.FindControl("Label1");

so you can try this option and see its help you

foreach(Control c1 in Master.Controls) {}


MP

I never desire to converse with a man who has written more than he has
read. -Samuel Johnson, lexicographer (1709-1784)
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Beginning ASP.NET 2.0 in C# 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1148, Published: 2006
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages Authors: Jacob J. Sanford, Pages: 474, Published: 2007
Pro Tools for Music Production: Recording, Editing and Mixing Authors: Mike Collins, Pages: 400, Published: 2004
Sams Teach Yourself Visual Basic 6 in 21 Days Authors: Greg M. Perry, Sams Publishing (Firm), Pages: 851, Published: 1998
Master Visually Creating Web Pages: Creating Web Pages Authors: Joe Kraynak, Pages: 421, Published: 2004
Dynamics and Control in Nuclear Power Stations: Written Symposium : Papers Authors: M. H. Butterfield, British Nuclear Energy Society, British Nuclear Energy Society, Pages: 203, Published: 1992

Web:
Looping Through Controls in Master Pages - ASP.NET Forums Is there anyway to find the "main control" on a form and loop through them all, when using master pages, without having to do a massive ...
Loop through Master Page Controls - ng.asp-net-forum ... NET » Master Pages, Themes and Navigation Controls ... i loop through all the controls within this contentplaceholder, or the whole page ? ...
microsoft.public.dotnet.framework.aspnet: Re: Loop through ... The hierarchy of controls with MasterPages looks like this: ... For Each ctlMaster As Control In ... >longer loop through the controls on the content page. ...
Find Controls In MasterPages Recursively (C# Code) • Geekpedia Animated Popup Master/Detail using. ... Find Controls In MasterPages Recursively ... Controls) // Loop through all the controls of the current element ...
MasterPages Template Properties in .NET v1.* - Paul Wilson's .NET Blog re: MasterPages Template Properties in .NET v1.*. You should be able to loop through the page's controls and find the HtmlForm without any problem -- just ...
FindControl and Master Pages | SADev.co.za Aug 5, 2007 ... You could build a recursive find control method which searches master pages and content pages control internally looping through each ...
Loop through the controls on an ASP.NET page using a Master Page ... Loop through the controls on an ASP.NET page using a Master Page ... 2, ASP.NET 2.0 Master Pages and javascript How do I access the A… ASP.Net Programming ...
Loop Through All Controls on an ASP.net Webpage - KrisSteele.net Oct 9, 2008 ... The basicic heirachy of controls on a page (which uses MasterPages) is ... In order to loop through all of these and get to the controls you ...
ASP.NET 2.0 MasterPages and FindControl() - Rick Strahl's Web Log ASP.NET Forums - contentplaceholder - how to loop through form values ? by Master Pages, Themes and Navigation Controls October 09, 2006 @ 9:50 am ...
Loop through controls with MaterPage ContentHolder - .NET ASP you loop through the controls on the master page and how do you loop through ... The hierarchy of controls with MasterPages looks like this: ...

Videos:
Using ROSE to Mitigate Performance Trade-offs Google TechTalks April 03, 2006 Daniel Quinlan ROSE is a tool for building source-to-source transformation tools for the optimization of C and C++ ...
Philip Pocock 100 Days 100 Guests event (Day 63) Documenta X 1997 Philip Pocock speaking at Documenta X about hypercinema and the collabortative work produced in Uganda by Documenta X - A Description of the Equator ...












design templates

menu control loses formatting in masterpage

help save a poor programmer's health - menu text color...

hide asp:menuitem

accessing user provider in a masterpage

adding image as a watermark to all web pages

can vwd 2005 express have more than one web.sitemap?

can't pass parameter to stored proc from treeview control

dynamically set theme from master page

make sitemappath choose right provider

how to expand treeview which gets its data from a sitemap only by clicking on the text of a node

is treeview far less useful than it looks

why would i start gettin this error now??

treeview and vertical scrolling

reload masterpage after menuitem_click

.sitemap open with

displaying a text box next to tree node

redirect problem in master page

how to toggle skinned images client side?

how to display different title in one master page

how to access the menuitem through javascript

codebehind of nested masterpages

menu control

i am having problems with... custom back button help/suggestions

text appears larger over https than over http

problem with meta-tag "/" removed

what would keep a skin from being applied

using javascript in asp.net 2.0 with master content pages.

dot net menu

how to bind treeview control to site map with root node

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT