473,767 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why can't I get the value when I disable a control?

I have code that will set a drop-down list value to "xyz" and the .Enabled
property to False. However, when I do that I can no longer retrieve the
value "xyz" upon postback. It is as if I set the .Visible property to False
as well and the control wasn't rendered, but I did not. If you View Source
of the rendered HTML, you can see that the control is indeed still intact
(everything is the same except the disabled argument is set to "disabled") .

Why can't I get the value when I disable a control?

Thanks,
Mike
Nov 17 '05 #1
6 1285
That is by design.

What you can do however is to set a hidden form field to the value of the selectbox just before you disable it, and retrieve that instead.

Hope that helps,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 17 '05 #2
Hi Wim,

Is it by design for version 1.1? I am using 1.0 and this is not happening.
Thanks,

Lenny

"Wim Hollebrandse" <wim@-NOSPAM-wimdows.net> wrote in message
news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
That is by design.

What you can do however is to set a hidden form field to the value of the selectbox just before you disable it, and retrieve that instead.
Hope that helps,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/

Nov 17 '05 #3
Thanks Wim,
Good idea,
Mike

"Wim Hollebrandse" <wim@-NOSPAM-wimdows.net> wrote in message
news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
That is by design.

What you can do however is to set a hidden form field to the value of the selectbox just before you disable it, and retrieve that instead.
Hope that helps,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/

Nov 17 '05 #4
In article <ed************ **@tk2msftngp13 .phx.gbl>, L. L. wrote:

Is it by design for version 1.1? I am using 1.0 and this is not happening.


It's by design in the HTML spec. ASP.NET versions have nothing to do
with it. Browsers aren't supposed to submit the values of disabled
controls.

Nov 17 '05 #5
It's as per the W3C HTML standards.

http://www.w3.org/TR/REC-html40/inte...ssful-controls

I am pretty sure it is the same for version 1.0 as its a browser/HTML issue and does not really have any bearing on the serverside controls (as long as they render the disabled attribute).

Cheers,
Wim
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 17 '05 #6
Mike,

For a dropdown, you don't set the value like
DropDownList1.S electedItem.Val ue = "xyz". Instead, you do this
DropDownList1.S electeIndex = i; //i is the index of value "xyz" in the
dropdown, starting from 0.

Make sure only set it once in the Page_Load event like,

if(!Page.IsPost Back)

{

DropDownList1.S electedIndex = 1;

DropDownList1.E nabled = false;//you can still get the value on postaback

DropDownList1.V isible = false;//you can still get the value on postaback

}

In the postback, I am sure you can get the value through code like,

string ddlvalue = DropDownList1.S electedItem.Val ue;

It doesn't matter the ddl is enabled or not. The ddl can even be invisible.

L.L.

"Mike Hnatt" <do**@gladsto ne-inc.com> wrote in message
news:vp******** ****@corp.super news.com...
I have code that will set a drop-down list value to "xyz" and the .Enabled
property to False. However, when I do that I can no longer retrieve the
value "xyz" upon postback. It is as if I set the .Visible property to False as well and the control wasn't rendered, but I did not. If you View Source of the rendered HTML, you can see that the control is indeed still intact
(everything is the same except the disabled argument is set to "disabled") .
Why can't I get the value when I disable a control?

Thanks,
Mike

Nov 17 '05 #7

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

Similar topics

2
7575
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run the VB program on that same machine, I can view the ActiveX control fine. He is using Citrix. The same ActiveX controls can be viewed on other machines. When trying to view 1 of the ActiveX control, he got an error "Visual Basic Run-time redist...
1
1535
by: Hardy Wang | last post by:
Guys, I have a web form with some <Asp:TextBox> controls, on some condition, I need to trigger a client side JavaScript to clean all values of these boxes, like below: function DisableForm() { document.getElementById("UserCtrl_Text_97").value = ""; document.getElementById("UserCtrl_Text_97").disabled = true; document.getElementById("UserCtrl_Text_98").value = "";
4
1667
by: Ken Varn | last post by:
I am trying to cut down the amount ViewState data that is passed to the client browser. I have a number of Web Server Controls on my page, but I am confused as to when ViewState can be disabled to save on web traffic. For instance.... I have several drop down listboxes. If I disable ViewState, then my server side code cannot obtain the selected item when the form is submitted. The thing that confuses me is that this should be...
0
3366
by: Robert Ladd | last post by:
Hi, I'm trying to disable the asp.net calendar control from a javascript function, but it doesn't disable the doPostBack. To simplify the situation, assume a page with 4 controls. A dropdownlist, a calendar control, a textbox and an update button. What I'm doing is initially setting the button to disabled, the other 3 controls are enabled. If any data is entered in the textbox, I want to disable the dropdownlist and the calendar...
13
14577
by: Rich | last post by:
Hello, So I would like to disable a textbox on a vb.net form without the text getting grayed out. In vb6 I could place a textbox control on a frame control and disable the frame leaving the textbox enabled and text/background were intact but mouse cursor remained an arraw (as opposed to an I for editable). I tried a Panel control on my .net form since I could I guess there is no longer a frame control (also tried a groupbox control)....
6
1519
by: | last post by:
hi, how to disable the controls in page? thanks For each myControl in Page.Controls 'want to disable myControl? Next
4
2486
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code m_Token = null in order to destroy the session token when the user logs out. However, I'm finding that setting class instance to null results in no header being sent back to the client, with the result that the client actually remains with an...
8
5120
by: freeskier | last post by:
I have been using the following code to cycle through a subform and disable all textboxes on a form. If a textbox on the form has the focus when this is run I get error "can't disable a control when it has the focus." When I add a line like "txtTest.SetFocus" where txtTest is a textbox on the main form I still get the same error. How do I resolve this issue? Also, please note that I disable all controls on the subform. Private Sub...
4
11952
by: mark4asp | last post by:
I have an element, report which contains tags which have been transformed. E.g. <pis &lt;p&gt <myXml> <report>This text has html tags in it.&lt;p&gt which but <has been changed to &lt;&gt</report> </myXml> I there a way that the XSLT transformation can render the content as html rather than text?
0
9571
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
9405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10169
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
10013
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
9841
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
8838
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7383
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5280
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...
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.