disabling a button server-side then re-enabling client-side breaks button postback
Posted on
16th Feb 2014 07:03 pm by
admin
I have a tabbed container and a button (not in the container) on a page. If the first tab is selected, I want the button enabled. If the second is selected, I want the button disabled. I have created this functionaliity, but I have encountered some odd behavior.
Switching tabs is handled client-side, and therefore, when the tabs are switched, I use something like the following to enable/disable the button client-side based on which tab is selected:view plaincopy to clipboardprint?var saveButton = document.getElementById("<%= btnSave.ClientID %>") if (saveButton) { saveButton.disabled=false; if mytab=="Tab2") { saveButton.disabled=true; } } var saveButton = document.getElementById("<%= btnSave.ClientID %>")
if (saveButton) {
saveButton.disabled=false;
if mytab=="Tab2") {
saveButton.disabled=true;
}
}view plaincopy to clipboardprint? view plaincopy to clipboardprint?This works great but the first problem I run into is, if a control on the second tab (the button is disalbed when this tab is selected) causes a postback, then after the postback the button's state is returned to enabled. This sort of makes sense since the page lifecycle, at this point, knows nothing about what the button state should be. I decided the solution to this would be to check what the current tab is during page load, and if it is the second tab, set the button enabled property to false. In this way, when a postback occurs on the second tab, the button remains disabled. Well, this works to a charm, but I encountered a bizzare side-effect. This works great but the first problem I run into is, if a control on the second tab (the button is disalbed when this tab is selected) causes a postback, then after the postback the button's state is returned to enabled. This sort of makes sense since the page lifecycle, at this point, knows nothing about what the button state should be. I decided the solution to this would be to check what the current tab is during page load, and if it is the second tab, set the button enabled property to false. In this way, when a postback occurs on the second tab, the button remains disabled. Well, this works to a charm, but I encountered a bizzare side-effect.view plaincopy to clipboardprint? view plaincopy to clipboardprint?On the second tab, a postback is caused. The button remains disabled as it should be. I then swith tabs. The client-side code goes into effect and the button client-side disabled property is set to false. However the strange thing is, now the button doesn't work. Clicking on it does not cause a postback and doesn't really do anything. It seems that setting the button enabled property to false and then true server-side, somehow doesn't jive with setting it's disabled property to false on the client. On the second tab, a postback is caused. The button remains disabled as it should be. I then swith tabs. The client-side code goes into effect and the button client-side disabled property is set to false. However the strange thing is, now the button doesn't work. Clicking on it does not cause a postback and doesn't really do anything. It seems that setting the button enabled property to false and then true server-side, somehow doesn't jive with setting it's disabled property to false on the client.view plaincopy to clipboardprint? view plaincopy to clipboardprint?anyone have an idea what is going on?
Your Answer:
Login to answer
96
11
Other forums
a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca
Warning: session_start() [function.session-start]: Cann.....
hi, can someone help me with this? I keep getting this error....
Warning: session_start() [fu
unoconv doc convert to pdf code prob
PHP/5.3.1
Hi. I am trying to use this code to convert docs to .pdf utilizing unoconv. Howe
A Few Questions
Hi, I want to ask a few questions that I can't seem to find..
1) I'm creating a "shortcu
how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy
need to apply an if/else statement to Tim Thumb script
Not sure how to work this. I essentially want to call a variety of image sizes based on which style
need help with this contact form
I made this form and I need it to read the data and write the data to a table and its not working ca
Storing the referrer in session... problems with tabs
Hello All
I am currently working on an ERP project based on the MVC methodology, when a user
System copy error in RUN ABAP REPORT PHASE
Hi,
I am performing system copy on my test server. I have previously taken export of JAVA + A
Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of