468,249 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Javascript populated TextBox reverting on PostBack

I have a form that is built pretty much entirely at run time.

I load a collection of Categories which have multiple Plans.

Each Plan has a RadioButton.

Each Category has a single PriceTag TextBox that is populated with a
Price when a RadioButton is selected. This is done through a
Javascript method.

The PriceTag may be filled out on Page Load depending on whether a
RadioButton was selected the last time they came in to the page and
saved.

If they select a different RadioButton under a Category, the PriceTag
updates correctly through Javascript.

I have multiple CustomValidators on the form.

If the user submits the form and one of these CustomValidators comes
back as InValid on the Server-Side Validation routine the form reloads
itself, and any RadioButtons that were changed are still in the
changed state, but the PriceTag TextBoxes are now repopulated with
what they were when the form first loaded.

I have been through every thing I can think of, working on it for days
and it's driving me insane. Anyone got any advice?

By the way, when I load the RadioButtons and PriceTags I specifically
check to see if it is a Postback...if it is I don't assign any value
to them at all (the values get put back in their by ViewState)
Oct 17 '08 #1
2 2214
most likely the textboxes are disabled. the browser will not postback
any disabled form fields. the easiest workaround is to have the
javascript write the values to a hidden field that will be posted back.

-- bruce (sqlwork.com)
Pselus wrote:
I have a form that is built pretty much entirely at run time.

I load a collection of Categories which have multiple Plans.

Each Plan has a RadioButton.

Each Category has a single PriceTag TextBox that is populated with a
Price when a RadioButton is selected. This is done through a
Javascript method.

The PriceTag may be filled out on Page Load depending on whether a
RadioButton was selected the last time they came in to the page and
saved.

If they select a different RadioButton under a Category, the PriceTag
updates correctly through Javascript.

I have multiple CustomValidators on the form.

If the user submits the form and one of these CustomValidators comes
back as InValid on the Server-Side Validation routine the form reloads
itself, and any RadioButtons that were changed are still in the
changed state, but the PriceTag TextBoxes are now repopulated with
what they were when the form first loaded.

I have been through every thing I can think of, working on it for days
and it's driving me insane. Anyone got any advice?

By the way, when I load the RadioButtons and PriceTags I specifically
check to see if it is a Postback...if it is I don't assign any value
to them at all (the values get put back in their by ViewState)
Oct 18 '08 #2
The textboxes are not disabled and I actually DO have a hidden field
that the values are being written too.

The problem is that when I re-creating my controls on Postback, during
my PageLoad the new values that the user selected are not in the
textboxes and the old values get assigned to the textbox.

The same problem is happening with some radio buttons I have now.
If I have two radio buttons created dynamically and neither are
checked, when one is checked by the user and they postback, the form
comes back with neither radio button checked again.
Oct 20 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Phil | last post: by
4 posts views Thread by Peter | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.