Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 23rd, 2007, 02:19 PM
Friend of Wrox
Join Date: Apr 2004
Location: San Francisco, CA, USA.
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to tell a User Control Who its Daddy is

I'm building a Content Management System that allows the user to dynamically change the MasterPageFile property of a page. I have 4 MasterPages setup that look different, but have all the same code on them. Each of them inherits from a base class I defined called BaseMasterPage. I got this from an excellent article on the subject located at http://odetocode.com/Articles/450.aspx.

Each MasterPage has this one user control on it. I handle the events of the control in the MasterPage, using the RaiseBubbleEvent method inside the user control.

The problem is that the user control is bubbling its events to the MasterPage declared in the @Page directive, not the one we dynamically changed to during the page's PreInit event. Then events on the User Control bring back controls that weren't originally in the ViewState. Since I'm using an UpdatePanel, I get the "Cannot Load ViewState" error.

How can I tell the control which MasterPage to bubble its events to?


  #2 (permalink)  
Old March 23rd, 2007, 04:25 PM
Friend of Wrox
Join Date: Apr 2004
Location: San Francisco, CA, USA.
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts

Nevermind, I figured this out.

The problem was that in the page's preInit ...

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
     If IsPostBack = False Then     'this was the mistake
          Me.MasterPageFile = "~/MasterPages/Level" & dr("intMaster").ToString & "Master.Master"
     End If
End Sub
By only doing this when isPostback was false, I was basically insuring that any event that triggered an asynchronous postback would bring back different ViewState data with it. Stupid mistake. Oh Well.



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to tell a User Control Who its Daddy is Aaron Edwards ASP.NET 2.0 Basics 1 March 23rd, 2007 04:25 PM
VWD 2005 Expr - Go Daddy SQL Server problem dmitcha Visual Studio 2005 2 January 2nd, 2007 09:32 AM
MS Access/Go Daddy Connections jroxit Classic ASP Basics 1 September 18th, 2006 12:32 PM
Add Windows User control in Web User Control agarwalvidhu C# 0 March 30th, 2006 01:17 AM
Help! Custom Server Control using User Control diehard ASP.NET 1.0 and 1.1 Professional 2 January 4th, 2006 12:33 PM

All times are GMT -4. The time now is 10:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.