I am actually doing something a little different. We have some base functionality in our base page that I can't talk about, but I addition we wanted masterpages. Also, we have multiple different sites are using this base class. So what we did was specify a user control that would be the master page that specifies the layout of the master page (and the control that will be the container of derived pages. In this way, the base class has no <form> since it does not have a aspx page. The master page control doesn't have a <form> either since we don't need it in our case. This issue with validators are the first real stumbing block. I hope it's the last.
Thanks, Shawn Wildermuth [EMAIL PROTECTED] Author of Pragmatic ADO.NET http://adoguy.com/book http://ONDotnet.com Microsoft .NET MVP > -----Original Message----- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of > Michael Giordano > Sent: Wednesday, February 04, 2004 7:13 PM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] Fiddling with Controls > collection in ASP.NET > > Shawn, > > I did something very similiar and ran into the same problem. > > Have a look here : > > http://www.codeproject.com/aspnet/page_templates.asp > > There is a bunch of relevant info there. > > HTH, > Mike G. > > * > The power of the waterfall is nothing more than a bunch of > drips working together. > * > > > > > > >From: Shawn Wildermuth <[EMAIL PROTECTED]> > >Reply-To: "Moderated discussion of advanced .NET topics." > ><[EMAIL PROTECTED]> > >To: [EMAIL PROTECTED] > >Subject: [ADVANCED-DOTNET] Fiddling with Controls collection > in ASP.NET > >Date: Wed, 4 Feb 2004 16:20:53 -0500 > > > >Caveat: I decided to post it to Advanced since what I am > trying to do > >is a little ASP.NET black magic. > > > >I have created a base ASP.NET class that derives from > System.Web.UI.Page. > >This class's job is to create a master page for all Pages in a > >particular application. In this class I do the following: > > > >- On it's OnInit() call, I gather all the controls for the > > page's HtmlForm object and remove them from the HtmlForm's > > Controls collection. > >- I then load a specific UserControl that contains the master > > page information. > >- Lastly, I add all the controls that used to live in the > > HtmlForm'ss Control's collection to a control within > > the Master Page User Control. > > > >All of this worked well until I ran into validators. Quick > background > >on client-side validation. When a page has validators, > client scripts > >are added to the page and ultimately called from a submit > button on the page. > >After generating a page, a typical button goes from: > > > ><asp:Button id="Button1" runat="server" Text="Button"></asp:Button> > > > >And makes it: > > > ><input type="submit" > > name="WebUserControl11:Button1" > > value="Button" > > onclick="if (typeof(Page_ClientValidate) == 'function') > >Page_ClientValidate(); " > > language="javascript" > > id="WebUserControl11_Button1" /> > > > >The magic is the onclick event. This forces the page to > validate. The > >problem is that with my base page class this fixup when it > renders the > >button never happens. I've delved into a myriad of possible > solutions > >and have concluded the following information: > > > >- Changing the time when the control fiddling happens > > seems to have no affect. > >- Embedding a form within another control (using a User > > Control) does not make this happen. > >- Commenting out the code that does the re-parenting of > > the controls in my base class resolves the issue (but > > obviously doesn't really fix it). Therefore the > > subclassing of the Page class is not the issue. > > > >What I am looking for is some insight to how the validator > code fix-ups > >happen. I am happy to reverse engineer the rendering to see when it > >happens to find clues as how to get around the issue, but I > haven't had > >any success with Reflector yet. Anyone run into this or can > give me an > >idea of where to start to look about where the fixup > rendering happens? > > > >TIA > > > > > >Thanks, > > > >Shawn Wildermuth > >[EMAIL PROTECTED] > >Author of Pragmatic ADO.NET > >http://adoguy.com/book > >http://ONDotnet.com > >Microsoft .NET MVP > > > >=================================== > >This list is hosted by DevelopMentorR > http://www.develop.com Some .NET > >courses you may be interested in: > > > >NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles > >http://www.develop.com/courses/gaspdotnetls > > > >View archives and manage your subscription(s) at > >http://discuss.develop.com > > _________________________________________________________________ > Check out the coupons and bargains on MSN Offers! > http://shopping.msn.com/softcontent/softcontent.aspx?scmId=1418 > > =================================== > This list is hosted by DevelopMentorR http://www.develop.com > Some .NET courses you may be interested in: > > NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles > http://www.develop.com/courses/gaspdotnetls > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 26 Jan 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
