Weird Literal rendering behavior

  • Thread starter Thread starter Scott L
  • Start date Start date
S

Scott L

I have a button and a literal on my page (among other things but *I think*
this functionality is pretty much isolated).

1. In Page_Init I set literal.Text = "PAGEINIT"

2. In the button's click method I set literal.Text = "BUTTONCLICKED"

3. In Page_PreRender I verify that literal.Text == "BUTTONCLICKED" after
clicking the button.

4. As soon as I step out of Page_PreRender the page is rendered with
literal.Text == "PAGEINIT"

If I specifically set literal.Text = "MANUALLYSET" in Page_PreRender, then
literal.Text == "MANUALLYSET" when the page renders. I'm stumped. Why is
the Text set in the button's click method carried through to Page_PreRender
but then not rendered in the browser? Why does manually setting the value in
Page_PreRender work when the value that is in literal.Text at the time of
Page_PreRender is ignored?

Any help is greatly appreciated as I'm about to lose it...
 
You're right, my bad. If anyone cares, it turns out that implementing a
partial page update in ASP.NET webforms can cause unexpected behavior in
unrelated parts of the page. Lame.
 
Back
Top