473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DropDownBox value after postback differs...

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
Mar 21 '06 #1
2 1727
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)


"Lars Netzel" <ui****@adf.se> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl...
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

Mar 21 '06 #2
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
"Bruce Barker" <br******************@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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)


"Lars Netzel" <ui****@adf.se> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl...
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


Mar 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: thomas j | last post by:
Hi, I have a MySqlBase with a tabel named CARS and with 3 fields; CarsType, CarsModel, CarsInfo. Now I want to generate 2 dropdownboxes in PHP read from CARS. First I will "load" CarsType into...
1
by: Jim Heavey | last post by:
Hello I have a datagrid that has a footer that I have place a dropdownbox on and loaded the values in the datalist in the ItemCreated Event. Everything is just as I expected when the grid is...
1
by: Mad Scientist Jr | last post by:
I don't know how this is happening, but a dropdown control I have is resetting to the 2nd value on the list anytime a postback occurs. I have no initiation code outside of If Not (IsPostBack) ...
0
by: Sunil Sabir | last post by:
Dear All, I have a web form which has a link and a drop down box. when I press a link a pop up window opens. This window has a lot of TEXTBOXES and a Save button. When I fill the TextBoxes and...
3
by: Dave Adler | last post by:
Is there any way to retain the value of an HtmlInputFile control through a postback? I do some server side validation on the page when it is submitted and if an error occurs on the page the...
0
by: Danny M | last post by:
When i change the value in the dropdownbox. The value changes. When i check the datatable the value has changed But when i want to save it to the database the record didnt got a changed flag...
3
by: iskeletor | last post by:
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #define STUDENT_NUMBER 68 #define ARRAY_LENGTH 10 struct node{ char Name,Surname; int data,no;
0
by: cartman83 | last post by:
I've got a dropdownbox with a few values in it. There is one value that is selected in advance. But when I change the value in the dropdownbox to a larger amount and press "Search" the value that...
3
by: Uriah Piddle | last post by:
Hi Gang, As far as transferring data goes, is putting a context.response.redirect statement in an event handler basically the same as setting the PostBackUrl prop for a control? So far, none of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.