Passing Server Control Values Between Pages

Discussion in 'ASP .Net' started by Matt M, Aug 28, 2003.

  1. Matt M

    Matt M Guest

    Ok. So I'm passing values between web pages, as per microsoft's framework
    development guide
    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
    ml/cpconPassingServerControlValuesBetweenPages.asp)

    So, I have two pages, one that has some public properties and fires a
    Server.Transfer("receivepage.aspx");

    The receivepage.aspx can then get some of the public properties I've set on
    the first page.

    What I really want to be able to do is call the receivepage.aspx from a
    variety of other pages. I am confused a little, because in the receivepage
    you have to reference the sending page

    i.e.

    public sendingpage callPage;

    private void Page_Load(object sender, System.EventArgs e)

    {


    if (!IsPostBack)

    {

    callPage = (sendingpage) Context.Handler;

    }

    How can I dynamically choose which page I want to reference? Is it
    possible? Thanks for any help.

    = matt =
     
    Matt M, Aug 28, 2003
    #1
    1. Advertising

  2. Matt M

    Matt M Guest

    Perfect. Thank you very much. I'm a little new to .NET and C# for that
    matter, so I will do your first option. I'm not too clear on the "deriving
    from a base class" part.

    Thanks.

    - matt -

    "John Saunders" <> wrote in message
    news:...
    > "Matt M" <matt@remove_this_core49.com> wrote in message
    > news:Ycc3b.861167$...
    > > Ok. So I'm passing values between web pages, as per microsoft's

    framework
    > > development guide
    > >

    >

    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
    > > ml/cpconPassingServerControlValuesBetweenPages.asp)
    > >
    > > So, I have two pages, one that has some public properties and fires a
    > > Server.Transfer("receivepage.aspx");
    > >
    > > The receivepage.aspx can then get some of the public properties I've set

    > on
    > > the first page.
    > >
    > > What I really want to be able to do is call the receivepage.aspx from a
    > > variety of other pages. I am confused a little, because in the

    > receivepage
    > > you have to reference the sending page
    > >

    > ...
    >
    > > How can I dynamically choose which page I want to reference? Is it
    > > possible? Thanks for any help.

    >
    > Matt, I may be misunderstanding your question, and if so, please forgive

    me.
    >
    > The receiver page naturally cannot choose which page transferred to it.
    > However, it can determine which page transferred to it:
    >
    > if (Context.Handler is PageType1)
    > {
    > PageType1 pt1 = (PageType1) Context.Handler;
    > // Reference pt1.Property
    > } else if (Context.Handler is PageType2)
    > {
    > PageType2 pt2 = (PageType2) Context.Handler;
    > // Reference pt2.Property
    > }
    > else
    > {
    > throw new Exception("I don't know what kind of page called me!");
    > }
    >
    > You say you want to call the receiver from multiple pages. Do all the
    > "sending" pages have the same set of properties? If that's the case, you
    > might want to create a base page class which contains all of those
    > properties and then have the sending pages all derive from it. Your code

    in
    > the receiving page would then be much simpler:
    >
    > if (Context.Handler is BaseSendingPage)
    > {
    > BaseSendingPage bsp = (BaseSendingPage) Context.Handler;
    > // Reference bsp .Property
    > }
    > else
    > {
    > throw new Exception("I don't know what kind of page called me!");
    > }
    > --
    > John Saunders
    > Internet Engineer
    >
    >
    >
     
    Matt M, Aug 28, 2003
    #2
    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. cgia
    Replies:
    5
    Views:
    795
    Steve C. Orr, MCSD
    Jul 26, 2003
  2. Greg Decos
    Replies:
    2
    Views:
    421
    Greg Decos
    Apr 15, 2004
  3. VS_NET_DEV
    Replies:
    2
    Views:
    3,839
    jenny
    May 25, 2004
  4. John

    Passing values between pages

    John, Oct 8, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    462
    Xavier Pacheco
    Oct 8, 2004
  5. Shankar Ayyachamy
    Replies:
    4
    Views:
    538
    IPGrunt
    Jan 28, 2005
Loading...

Share This Page