Label losing value on postback (i think) HELP!

Discussion in 'ASP .Net' started by TheAmes, Oct 30, 2006.

  1. TheAmes

    TheAmes Guest

    Hi

    I have a asp.net site in VB.NET and VWD 2005 Express.

    in the master page i have a Label.

    from a content page i change the value of this label like so:

    dim X as label = page.master.findcontrol("Label3")
    X.text = "Some Text Here"

    this is done on the click event of an image button.

    This works fine, the problem is when i navigate to any other page on my
    site the label text defaults back to nothing.

    im using iumage buttons and response.redirect, could this be the
    problem?

    Please help im going insane

    Andrew
     
    TheAmes, Oct 30, 2006
    #1
    1. Advertising

  2. Andrew,

    When you leave your page, it's gone. It is not a postback. Postback occurs
    when the page posts to itself. But even in a postback the page is built from
    scratch. Master forms just participate in this building process, they don't
    exists between the posts either. For a value to persist, you have to make it
    persistent somewhere and restore it in page load event.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "TheAmes" <> wrote in message
    news:...
    > Hi
    >
    > I have a asp.net site in VB.NET and VWD 2005 Express.
    >
    > in the master page i have a Label.
    >
    > from a content page i change the value of this label like so:
    >
    > dim X as label = page.master.findcontrol("Label3")
    > X.text = "Some Text Here"
    >
    > this is done on the click event of an image button.
    >
    > This works fine, the problem is when i navigate to any other page on my
    > site the label text defaults back to nothing.
    >
    > im using iumage buttons and response.redirect, could this be the
    > problem?
    >
    > Please help im going insane
    >
    > Andrew
    >
     
    Eliyahu Goldin, Oct 30, 2006
    #2
    1. Advertising

  3. TheAmes

    TheAmes Guest

    i originally tried using session variables, but i want it so everytime
    ia user clicks a certain button on a content page it increments the
    session variable by 1.

    the problem is the first time they press it , it does not increment.
    BUT after the first time it will increment? any ideas? need more info?


    Eliyahu Goldin wrote:
    > Andrew,
    >
    > When you leave your page, it's gone. It is not a postback. Postback occurs
    > when the page posts to itself. But even in a postback the page is built from
    > scratch. Master forms just participate in this building process, they don't
    > exists between the posts either. For a value to persist, you have to make it
    > persistent somewhere and restore it in page load event.
    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    >
    > "TheAmes" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I have a asp.net site in VB.NET and VWD 2005 Express.
    > >
    > > in the master page i have a Label.
    > >
    > > from a content page i change the value of this label like so:
    > >
    > > dim X as label = page.master.findcontrol("Label3")
    > > X.text = "Some Text Here"
    > >
    > > this is done on the click event of an image button.
    > >
    > > This works fine, the problem is when i navigate to any other page on my
    > > site the label text defaults back to nothing.
    > >
    > > im using iumage buttons and response.redirect, could this be the
    > > problem?
    > >
    > > Please help im going insane
    > >
    > > Andrew
    > >
     
    TheAmes, Oct 30, 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. Replies:
    0
    Views:
    647
  2. Replies:
    1
    Views:
    913
    Jack Klein
    Apr 13, 2005
  3. David Mark
    Replies:
    17
    Views:
    267
    David Mark
    Mar 23, 2010
  4. Jason C
    Replies:
    4
    Views:
    708
    Morty Abzug
    Jun 26, 2012
  5. Knut Krueger
    Replies:
    8
    Views:
    337
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page