Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Postback nightmares

0 views
Skip to first unread message

Doogie

unread,
May 1, 2008, 10:14:25 AM5/1/08
to
Basically, I have two custom dates the user can enter via a popup
calendar. These dates are stored into text boxes. Then the user can
click a button (Run Report) and those values (as well as others) are
used to build an SRS url string. This used to work before I modified
the page to make the calendar a popup.

Now, the text boxes lose their value when the user clicks the run
report button. I have verified this is happening because it’s doing a
postback, but the values are gone before page_load is called. I have
EnableViewState set to true for both text boxes and it’s not retaining
the values. I have tried variations of ways to fix this (set the
values in a view state object, enable view state on the page as a
whole, etc) and nothing is working.

Am I missing something?

Peter Bromberg [C# MVP]

unread,
May 1, 2008, 11:38:11 AM5/1/08
to
It sound like you are capturing the entered values from the popup
client-side, and therefore there is no server-side TextChanged event or
ViewState populated.
Of course, when the postback is created, you get two empty textboxes because
valuess populated in the browser don't get transmitted. Among other tricks,
you could try storing them in a cookie first - that can be done client-side
via javascript. Then read back the cookie on a postback and you can get your
values.
Peter

"Doogie" <dnlw...@dtgnet.com> wrote in message
news:036bd68e-8158-45ee...@27g2000hsf.googlegroups.com...

Doogie

unread,
May 1, 2008, 12:02:02 PM5/1/08
to
On May 1, 10:38 am, "Peter Bromberg [C# MVP]"

<pbromb...@nospammin.yahoo.com> wrote:
> It sound like you are capturing the entered values from the popup
> client-side, and therefore there is no server-side TextChanged event or
> ViewState populated.
> Of course, when the postback is created, you get two empty textboxes because
> valuess populated in the browser don't get transmitted. Among other tricks,
> you could try storing them in a cookie first - that can be done client-side
> via javascript. Then read back the cookie on a postback and you can get your
> values.
> Peter
>
> "Doogie" <dnlwh...@dtgnet.com> wrote in message

>
> news:036bd68e-8158-45ee...@27g2000hsf.googlegroups.com...
> Basically, I have two custom dates the user can enter via a popup
> calendar.  These dates are stored into text boxes.  Then the user can
> click a button (Run Report) and those values (as well as others) are
> used to build an SRS url string.  This used to work before I modified
> the page to make the calendar a popup.
>
> Now, the text boxes lose their value when the user clicks the run
> report button.  I have verified this is happening because it’s doing a
> postback, but the values are gone before page_load is called.  I have
> EnableViewState set to true for both text boxes and it’s not retaining
> the values.  I have tried variations of ways to fix this (set the
> values in a view state object, enable view state on the page as a
> whole, etc) and nothing is working.
>
> Am I missing something?

Turns out that the fact the text boxes are disabled is what is causing
the issue. Setting them to be enabled fixed the issue. Weird, not
sure why I wouldn't be able to do that. I have them disabled cause I
wanted them to only be filled by the calendar popup and not manually
entered.

Mark Rae [MVP]

unread,
May 1, 2008, 12:30:21 PM5/1/08
to
"Doogie" <dnlw...@dtgnet.com> wrote in message
news:c59f6994-27bd-48db...@34g2000hsf.googlegroups.com...

> Turns out that the fact the text boxes are disabled is what is causing
> the issue. Setting them to be enabled fixed the issue. Weird, not
> sure why I wouldn't be able to do that. I have them disabled cause I
> wanted them to only be filled by the calendar popup and not manually
> entered.

Aha! I've seen that before.

Had you disabled the textboxes in the actual markup i.e. in the <asp:TextBox
> tag?

If so, try disabling them in codebehind e.g.

TextBox1.Enabled = false;

or even

TextBox1.Attributes.Add("disabled", "disabled");


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Teemu Keiski

unread,
May 1, 2008, 3:12:33 PM5/1/08
to
Hi,

You could set submitdisabledcontrols="true" on the <form> element of the
page which makes asp.net to post also disabled textboxes values. I believe
disabled HTML form elements don't submit by default.

Other option is to set TextBox as readonly but that has to be done via
Attributes.Add
(http://aspadvice.com/blogs/joteke/archive/2006/04/12/16409.aspx) as setting
ReadOnly property prevents postback data from being loaded, meaning in
practise that TextBox doesn't keep its state (it's read-only from
server-side perspective)


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


"Doogie" <dnlw...@dtgnet.com> wrote in message

news:c59f6994-27bd-48db...@34g2000hsf.googlegroups.com...

0 new messages