Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp:Label value not outputting

Status
Not open for further replies.

kylemcna

Programmer
Joined
Dec 23, 2004
Messages
15
Location
US
Hi,

I have an issue where I am using Page_Load to write a value to a label on the aspx page and it appears that the first time I do it the value (in this case a url param value) is displaying correctly.

After the first time, the page does not break, but the Label does not get populated wth the value any more.

Any help on this would be hugely appreciated.

Thank you,

Kyle
 
Try putting it inside a
Code:
If Not page.ispostback then
label1.text = whatever
End Try
 
i had tried that with no luck... i want it to be availabel no matter what the IsPostBack value says though, so hopefully I should not have to do that.

I just tried a test page and it works fine (test.aspx and test.aspx.cs)... I wonder what could be going on.
 
I found the issue.

In case anyone is wondering or knows why on earth this happened:

I started comparing the #region Web Form Designer generated code of the test.aspx file with that of the fiels not working and I saw that somehow "this.Load += new System.EventHandler(this.Page_Load);" was removed from the "private void InitializeComponent()" event.

Putting that back in fixes the issue.

I certainly did not remove it and no one is working on this workstation except me and it appears to have happened more than once.

It says right in that block: "Required method for Designer support - do not modify the contents of this method with the code editor." I /never/ use design mode and anyway I never modify that block, so I don't care about design mode, but by the same token, I can't have VS taking out code from that block willy-nilly with no way of knowing why or when.

Anyone know why that could be happening?

Thank you,

Kyle
 
That is weird. I find it amusing that it says not to modify the code, but it will let you do so. Go figure! Sometimes that region is open when I return to the code page, and I know that I didn't open the region. Hopefully it hasn't erase any of my code though. You were really lucky finding that problem. I would never have found that!
 
Hey edelwater,

That appears related, but I am /never/ using design mode and I have not once changed the EnableViewState property in this particular app.

Is there a reasonthat you think that still applies?

Thank you!

Kyle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top