|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Controls calling other controls problem - ASP.NET 2.0I have a web page (content.aspx) that inherits from a master page (MasterPage.master). The master page has a control (which has to be on every web page, hence on the master page) (MasterControl.ascx). When placed on the master page this appears as <uc1:MasterControl ID="MasterControl1" runat="server" />. The MasterControl's Page_Init() event will contain some code to examine the Request object's properties (cookies) and calculate some value that it will expose as a property. This property is called "ImportantProperty()". Content.aspx has a specific control on it (ContentControl.ascx). When placed on the web page this appears as <uc1:ContentControl ID="ContentControl1" runat="server" />. The problem... The ContentControl.ascx's Page_Load() event must call the "ImportantProperty()" in the MasterControl. The resulting value dictates which view (another user control) to dynamically load at run time (View1.ascx, View2.ascx or View3.ascx). MSDN gives an example of how to call a property on the MasterControl from the Content.aspx page but NOT from a control on the Content.aspx page. Microsoft's example can be found on: http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx I've tried to amend their example without success....could someone put me out of my misery please? Many thanks Griff Have the page call to each control. Ultimately, the architecture is such
that both the user control and the web control are controls on the page. The control of painting is passed to the master page, which makes it appear different, but it is, in essence a user control. Your other option is to iterate through the page controls until you find the master page, use reflection and set the property. I have not personally tried this, but this is the only way I know of getting the property. -- Show quoteHide quoteGregory A. Beamer MVP; MCP: +I, SE, SD, DBA ************************************************* Think outside of the box! ************************************************* "Griff" <howl***@the.moon> wrote in message news:OrI8lmW3GHA.4764@TK2MSFTNGP02.phx.gbl... > Hi > > I have a web page (content.aspx) that inherits from a master page > (MasterPage.master). > > The master page has a control (which has to be on every web page, hence on > the master page) (MasterControl.ascx). When placed on the master page > this appears as <uc1:MasterControl ID="MasterControl1" runat="server" />. > > The MasterControl's Page_Init() event will contain some code to examine > the Request object's properties (cookies) and calculate some value that it > will expose as a property. This property is called "ImportantProperty()". > > Content.aspx has a specific control on it (ContentControl.ascx). When > placed on the web page this appears as > <uc1:ContentControl ID="ContentControl1" runat="server" />. > > The problem... > > The ContentControl.ascx's Page_Load() event must call the > "ImportantProperty()" in the MasterControl. The resulting value dictates > which view (another user control) to dynamically load at run time > (View1.ascx, View2.ascx or View3.ascx). > > MSDN gives an example of how to call a property on the MasterControl from > the Content.aspx page but NOT from a control on the Content.aspx page. > Microsoft's example can be found on: > http://msdn2.microsoft.com/en-us/library/c8y19k6h.aspx I've tried to > amend their example without success....could someone put me out of my > misery please? > > Many thanks > > Griff > Hi
Do you have any code example? I'm just not sure how the Content Page's User Control can access properties on the Master Page's User Control.... Thanks Griff
Control events - page life-cycle
OnDocumentReady with Treeview HTC (in a popup) ASP.NET 2.0 / GridView / ObjectDataSource / Update / Missing Columns The parameter is not correct from SqlDataAdapter control How to keep state of treeview control A Repeater Question. gridview with hyperlinkfield Slow menu control in IE with large grid, fast is FF ASP.NET report viewer chart control dual axis support Gridview - disappearing data when column is hidden |
|||||||||||||||||||||||