Controls calling other controls problem - ASP.NET 2.0

Discussion in 'ASP .Net Web Controls' started by Griff, Sep 21, 2006.

  1. Griff

    Griff Guest

    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
    Griff, Sep 21, 2006
    #1
    1. Advertising

  2. 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.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************************************************
    Think outside of the box!
    *************************************************
    "Griff" <> wrote in message
    news:...
    > 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
    >
    Cowboy \(Gregory A. Beamer\), Sep 21, 2006
    #2
    1. Advertising

  3. Griff

    Griff Guest

    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
    Griff, Sep 21, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob Rock
    Replies:
    1
    Views:
    627
    Cowboy \(Gregory A. Beamer\)
    Sep 17, 2006
  2. Griff
    Replies:
    2
    Views:
    544
    Griff
    Sep 21, 2006
  3. jim
    Replies:
    4
    Views:
    1,483
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Dec 20, 2007
  4. Headless Rider

    Control asp.net app from other asp.net app

    Headless Rider, Aug 18, 2003, in forum: ASP .Net Security
    Replies:
    0
    Views:
    100
    Headless Rider
    Aug 18, 2003
  5. Replies:
    7
    Views:
    121
    Mumia W. (reading news)
    Nov 16, 2006
Loading...

Share This Page