473,800 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1754
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.s e> wrote in message
news:ed******** ******@TK2MSFTN GP11.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.c om> wrote in message
news:%2******** ********@TK2MSF TNGP14.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.s e> wrote in message
news:ed******** ******@TK2MSFTN GP11.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
2018
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 an dropdownbox, and then I make a choice, exampel FORD, now the next dropdownbox (CarsModel) will show Escort, Sierra and so... Finally I will make a "actionbutton" named showinfo and when I click it will show CarsInfo.
1
1226
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 presented. I select some value from the DropDownList and then press a command button, also on the footer. By the time I get to the event which handles the button click event (CommandName Property in the datagrid), the
1
3658
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) I have EnableViewState set to true for the control - the control stays populated, it just is losing its selected value. The control is not contained in any panels or anything, just a Web
0
967
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 press save the POP UP window closes. Actually this POP UP window is a record of an employee. so basically I am filling the personal information of the employee. What I want is that when I press save Button the POP UP window must close. And It...
3
4557
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 HtmlInputFile control value is blank after the postback. The EnableViewState for the control is set to true. I can't put the postedFile.filename value in a hidden control and then put it back into the HtmlInputFile control on postback because the...
0
913
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 When i do dtTest = dtData.getchanges then dtTest is nothing ??? But still the value in the datatable has the right value, but because it didnt have a change flag it isnt saved to the database??? What i am doing wrong??
3
2638
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
1028
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 continues is the standard value. Here is my code: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load FillList() End Sub Private Sub FillList() Dim oNewTable As HtmlTable
3
317
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 my pages use data from a previous page. Assuming that these two methods both send their data to the new page, would it be good practice to use the Server.Transfer method of navigating whenever no data from the previous page is needed? Thanks. ...
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.