access to page from user control

Discussion in 'ASP .Net' started by Alex Wagner, Apr 20, 2004.

  1. Alex Wagner

    Alex Wagner Guest

    I've been trying to gain access to the container page from within a user
    control. Case in point:

    From within the user control I need to call a method in the business layer
    that needs a reference to the aspx page. The method signature looks like:

    public static void MyMethod(System.Web.UI.WebControls.WebControl
    MyWebControl, System.Web.UI.Page MyPage, string SomeOtherVariable)

    what am I supposed to pass in for the MyPage parameter??

    Thanks.
    Alex Wagner, Apr 20, 2004
    #1
    1. Advertising

  2. Alex Wagner

    Alex Wagner Guest

    I love newsgroups... after posting I always find my own answers... ;)

    Here's what I did:

    instead of calling the method from the aspx page like
    MyMethod(txtMyControl, this, "someValue");
    I call it like this from the user control:
    MyMethod(txtMyControl, (System.Web.UI.Page)this.Parent.Page,
    "someValue");

    voila.



    "Alex Wagner" <> wrote in message
    news:...
    > I've been trying to gain access to the container page from within a user
    > control. Case in point:
    >
    > From within the user control I need to call a method in the business layer
    > that needs a reference to the aspx page. The method signature looks like:
    >
    > public static void MyMethod(System.Web.UI.WebControls.WebControl
    > MyWebControl, System.Web.UI.Page MyPage, string SomeOtherVariable)
    >
    > what am I supposed to pass in for the MyPage parameter??
    >
    > Thanks.
    >
    >
    Alex Wagner, Apr 20, 2004
    #2
    1. Advertising

  3. Alex Wagner

    Matt Berther Guest

    Hello Alex,

    > public static void MyMethod(System.Web.UI.WebControls.WebControl
    > MyWebControl, System.Web.UI.Page MyPage, string SomeOtherVariable)
    >
    > what am I supposed to pass in for the MyPage parameter??


    this.Page

    --
    Matt Berther
    http://www.mattberther.com
    Matt Berther, Apr 21, 2004
    #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. qwerty
    Replies:
    3
    Views:
    9,262
    Scott Allen
    Sep 30, 2004
  2. digitalego
    Replies:
    1
    Views:
    659
    digitalego
    Mar 23, 2005
  3. Mad Scientist Jr
    Replies:
    0
    Views:
    622
    Mad Scientist Jr
    Mar 22, 2006
  4. Replies:
    5
    Views:
    55,755
    Sharals
    Jun 18, 2010
  5. Chris Zopers

    Access user control from other user control

    Chris Zopers, Feb 20, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    555
    Nanda Lella[MSFT]
    Apr 27, 2009
Loading...

Share This Page