473,395 Members | 1,422 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,395 software developers and data experts.

Controls disabled with javascript not posted back to server

Good evening. I was hoping someone can help me:

I have an ASP.NET page which contains an ArrayList bound to a
DataGrid. The DataGrid displays, in columns, a few members of the
objects in this ArrayList. Each object that is displayed (ie. each row
in the DataGrid) also has an "Add" and a "Remove" button. Think
Windows Update style here.

If you click the "Add" button, it becomes Disabled and the "Remove"
button is Enabled. Click on "Remove" and it becomes Disabled and the
"Add" button is Enabled. Just like Windows Update.

I manage that Enabling/Disabling with client side Javascript. I take
the Client ID and do a "btn1.disabled = true" (or false) on the button
objects.

When a "Submit" button is pressed, the server iterates through the
rows in the DataGrid and looks for buttons that are Enabled. This is
how the server would know which buttons you've enabled or disabled.
The problem is that the state that I set via JavaScript on the client
does not seem to make it back to the server.

Initially I have all the Add buttons enabled and all the Remove
buttons disabled. If I disable all the Adds, enable all the Removes,
the server still sees them all as Disabled. Any ideas why?
Nov 18 '05 #1
2 1594

"David Stahl" <da**@dontpokeme.com> wrote in message
news:14**************************@posting.google.c om...

<snip>
Initially I have all the Add buttons enabled and all the Remove
buttons disabled. If I disable all the Adds, enable all the Removes,
the server still sees them all as Disabled. Any ideas why?


Because the browser does not post all the properties with their values of
the form controls - only the (selected) values in <input type=text |
password | hidden | radio | checkbox> and <select> are posted.

You can, for example, on the click event of the buttons on the client-side,
set the value of a <input type=hidden> field and then read this in the
server.

Hope this helps
Martin

Nov 18 '05 #2
"Martin Dechev" <de*******@hotmail.com> wrote in message news:<#N**************@TK2MSFTNGP09.phx.gbl>...
Initially I have all the Add buttons enabled and all the Remove
buttons disabled. If I disable all the Adds, enable all the Removes,
the server still sees them all as Disabled. Any ideas why?


Because the browser does not post all the properties with their values of
the form controls - only the (selected) values in <input type=text |
password | hidden | radio | checkbox> and <select> are posted.


You rock!

This was the exact problem I was having and using the hidden input was
what I needed. Actually, I wound up using an asp:TextBox with
Visible=False and Width=0, but it put me on the right track.

Now I can finally go to bed with a clear head. Thanks again!

-D
Nov 18 '05 #3

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

Similar topics

6
by: Stu Carter | last post by:
Hi, I have an aspx page where some controls are initially disabled by the code-behind 'Page_Load' event. I want these controls to be dynamically enabled when the user checks a checkbox. ...
1
by: john | last post by:
I have two different problems: 1. When the user has clicked on a button that is causing the browser to post back to the server, it could take a little while for the new page to show up. So in...
5
by: Leo J. Hart IV | last post by:
Hello, I'm hoping someone can help me out. I was wondering if the Enabled property of a CheckBox or RadioButton server control is stored in the ViewState. If not, is there some way to to add...
7
by: Lau Lei Cheong | last post by:
Hello, I'm using javascript's insertAdjacentHtml() to insert images to the webform at runtime. This runs fine(image successfully displayed at the browser) but when I tried to access the...
22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
8
by: CsaaGuy | last post by:
I have a requirement to disable some textboxs depending on their contents. I choose to do this by invoking some javascript. When they change the contents, i disable the textbox they just put new...
5
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
2
by: Larry | last post by:
Is there a way to disable all the controls the instant any auto-postback controls are changed (resulting in a postback that takes a couple seconds), so that the user can't continue changing other...
2
Frinavale
by: Frinavale | last post by:
I've run into a bit of a problem concerning JavaScript and ASP.NET. Upon page submission I disable all of my buttons and would also like to disable all of my inputs (Textboxes, DropDownLists, etc)...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.