DropDownBox value after postback differs...

L

Lars Netzel

Hi

I'm having a DropDown box with 2 items... one with Value 1 and one with
Value 2.

If I load the page and it has Value 1 selected from page_load() and then
select Value 2 on the form.. .and then from a checkbox use javascript to
diasable to DropDownBox before I press a button to do the post back. So..
the DropDownBox has Value 2 but it manually disabled by me..

Then in the FormLoad in the postback.. I read the value.. and it's Value
1,,,how come?

Doesn't the viewstae update the value if the control is disabled?

best regards/
Lars Netzel
 
B

Bruce Barker

if a control is disabled, the browser will not post its value back to the
server, so the server can not know the new value.

the viewstate has the value at render (when page was built) and can not be
updated by client script. the viewstate value is compared the postback value
to determine if the value changed.

you can have client script enable the field just before postback (causes an
annoying flash), or have the clients script copy the value to a hidden field
which server code can copy value to dropdown, or if you really clever, the
client script at postback can create new hidden field with the same name as
the disabled control, and copy the value.

-- bruce (sqlwork.com)
 
L

Lars Netzel

OK, thank you. I just wanted to confirm this behavior. I actually I do not
really need the value from the Disabled control but it looked kind of funny
but I know now how to solve things.

Thank you very much!

/Lars
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top