Passing values across webforms that use Master pages

Discussion in 'ASP .Net' started by Chad, Jun 14, 2006.

  1. Chad

    Chad Guest

    Sorry to create a new thread on an old post but I didn't get a viable answer
    and thought that the odds were against me getting one unless I started a new
    thread.

    My question was this:

    I want to pass a string variable from default3.aspx to default2.aspx.

    I create a property in default2.aspx, called "X", and assign a value. I then
    call Server.Transfer("default3.aspx")

    In default3.aspx I have this code:
    Dim Default3 As Default3 = ctype(Context.Handler, Default3)
    Dim PassedString As String = Default3.x

    This will work fine as long a default 3 is not a webform that references a
    master page.

    If it is, it tells me that "Default 3" is an undefined type. As a result,
    the only way that I know o get it to work is to turn of Option Strict and
    change it to this:

    Dim Default3 As Object = Context.Handler
    Dim PassedString As String = Default3.x

    I really dont want to turn off Option Strict or resort to looselt typed
    variables.

    How do I correct this?
    Chad, Jun 14, 2006
    #1
    1. Advertising

  2. Chad,
    Try either putting the String name=value combo on the querystring, or into
    the HttpContext.Current.Items Collection. Not reasonable to expect a
    "property" of a page to survive a server.transfer or Response.Redirect.
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Chad" wrote:

    > Sorry to create a new thread on an old post but I didn't get a viable answer
    > and thought that the odds were against me getting one unless I started a new
    > thread.
    >
    > My question was this:
    >
    > I want to pass a string variable from default3.aspx to default2.aspx.
    >
    > I create a property in default2.aspx, called "X", and assign a value. I then
    > call Server.Transfer("default3.aspx")
    >
    > In default3.aspx I have this code:
    > Dim Default3 As Default3 = ctype(Context.Handler, Default3)
    > Dim PassedString As String = Default3.x
    >
    > This will work fine as long a default 3 is not a webform that references a
    > master page.
    >
    > If it is, it tells me that "Default 3" is an undefined type. As a result,
    > the only way that I know o get it to work is to turn of Option Strict and
    > change it to this:
    >
    > Dim Default3 As Object = Context.Handler
    > Dim PassedString As String = Default3.x
    >
    > I really dont want to turn off Option Strict or resort to looselt typed
    > variables.
    >
    > How do I correct this?
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Jun 14, 2006
    #2
    1. Advertising

  3. Chad

    Chad Guest

    Actually, it does work if you define Default3 as an Object. I was trying to
    strongly type the variable Default3 as an object of type "Default3" and it
    did not recognize the class "Defaulyt3" outside of the Default3 class.

    Try it. It does work.

    "Peter Bromberg [C# MVP]" <> wrote in message
    news:...
    > Chad,
    > Try either putting the String name=value combo on the querystring, or into
    > the HttpContext.Current.Items Collection. Not reasonable to expect a
    > "property" of a page to survive a server.transfer or Response.Redirect.
    > Peter
    >
    > --
    > Co-founder, Eggheadcafe.com developer portal:
    > http://www.eggheadcafe.com
    > UnBlog:
    > http://petesbloggerama.blogspot.com
    >
    >
    >
    >
    > "Chad" wrote:
    >
    >> Sorry to create a new thread on an old post but I didn't get a viable
    >> answer
    >> and thought that the odds were against me getting one unless I started a
    >> new
    >> thread.
    >>
    >> My question was this:
    >>
    >> I want to pass a string variable from default3.aspx to default2.aspx.
    >>
    >> I create a property in default2.aspx, called "X", and assign a value. I
    >> then
    >> call Server.Transfer("default3.aspx")
    >>
    >> In default3.aspx I have this code:
    >> Dim Default3 As Default3 = ctype(Context.Handler, Default3)
    >> Dim PassedString As String = Default3.x
    >>
    >> This will work fine as long a default 3 is not a webform that references
    >> a
    >> master page.
    >>
    >> If it is, it tells me that "Default 3" is an undefined type. As a result,
    >> the only way that I know o get it to work is to turn of Option Strict and
    >> change it to this:
    >>
    >> Dim Default3 As Object = Context.Handler
    >> Dim PassedString As String = Default3.x
    >>
    >> I really dont want to turn off Option Strict or resort to looselt typed
    >> variables.
    >>
    >> How do I correct this?
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    Chad, Jun 15, 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. =?Utf-8?B?Q2hyaXMgRmluaw==?=

    Master Pages: Sharing Across Web Servers

    =?Utf-8?B?Q2hyaXMgRmluaw==?=, Feb 27, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    380
    =?Utf-8?B?Q2hyaXMgRmluaw==?=
    Feb 28, 2006
  2. Doug McCann
    Replies:
    1
    Views:
    991
    William Brogden
    Aug 5, 2004
  3. Replies:
    1
    Views:
    3,189
    PeterKellner
    May 16, 2006
  4. Ily
    Replies:
    3
    Views:
    375
    Chris Fulstow
    Oct 18, 2006
  5. Aitham alama

    Passing values between two webforms

    Aitham alama, Jul 9, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    110
    Ken Cox [Microsoft MVP]
    Jul 10, 2004
Loading...

Share This Page