Passing Server Control Values Between Pages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt M

    #1

    Passing Server Control Values Between Pages

    Ok. So I'm passing values between web pages, as per microsoft's framework
    development guide
    (http://msdn.microsoft.com/library/de...-us/cpguide/ht
    ml/cpconPassingSer verControlValue sBetweenPages.a sp)

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

    The receivepage.asp x 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.asp x 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(objec t sender, System.EventArg s 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

    #2
    Re: Passing Server Control Values Between Pages

    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" <john.saunders@ surfcontrol.com > wrote in message
    news:uShLM5PbDH A.1280@tk2msftn gp13.phx.gbl...[color=blue]
    > "Matt M" <matt@remove_th is_core49.com> wrote in message
    > news:Ycc3b.8611 67$3C2.19338287 @news3.calgary. shaw.ca...[color=green]
    > > Ok. So I'm passing values between web pages, as per microsoft's[/color][/color]
    framework[color=blue][color=green]
    > > development guide
    > >[/color]
    >[/color]
    (http://msdn.microsoft.com/library/de...-us/cpguide/ht[color=blue][color=green]
    > > ml/cpconPassingSer verControlValue sBetweenPages.a sp)
    > >
    > > So, I have two pages, one that has some public properties and fires a
    > > Server.Transfer ("receivepage.a spx");
    > >
    > > The receivepage.asp x can then get some of the public properties I've set[/color]
    > on[color=green]
    > > the first page.
    > >
    > > What I really want to be able to do is call the receivepage.asp x from a
    > > variety of other pages. I am confused a little, because in the[/color]
    > receivepage[color=green]
    > > you have to reference the sending page
    > >[/color]
    > ...
    >[color=green]
    > > How can I dynamically choose which page I want to reference? Is it
    > > possible? Thanks for any help.[/color]
    >
    > Matt, I may be misunderstandin g your question, and if so, please forgive[/color]
    me.[color=blue]
    >
    > The receiver page naturally cannot choose which page transferred to it.
    > However, it can determine which page transferred to it:
    >
    > if (Context.Handle r is PageType1)
    > {
    > PageType1 pt1 = (PageType1) Context.Handler ;
    > // Reference pt1.Property
    > } else if (Context.Handle r 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[/color]
    in[color=blue]
    > the receiving page would then be much simpler:
    >
    > if (Context.Handle r is BaseSendingPage )
    > {
    > BaseSendingPage bsp = (BaseSendingPag e) Context.Handler ;
    > // Reference bsp .Property
    > }
    > else
    > {
    > throw new Exception("I don't know what kind of page called me!");
    > }
    > --
    > John Saunders
    > Internet Engineer
    > john.saunders@s urfcontrol.com
    >
    >[/color]


    Comment

    Working...