Label losing value on postback (i think) HELP!

  • Thread starter Thread starter TheAmes
  • Start date Start date
T

TheAmes

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
 
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.
 
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 said:
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 said:
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
 
Back
Top