Label losing value on postback (i think) HELP!

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
 
E

Eliyahu Goldin

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.
 
T

TheAmes

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top