Welcome Guest Search | Active Topics | Sign In | Register

Disable/enable datepicker with javascript Options
FPATER
Posted: Wednesday, August 19, 2009 11:58:49 AM
Rank: Member
Groups: Member

Joined: 3/11/2009
Posts: 24
I have a checkbox that will enable/disable 2 datepickers. When I run the following line of code and sender.checked == false the textbox grays out but you can still type in it. Also the calendar icon is enabled and when click it the calendar windows popups. How can I disable/enable the control completely?

Code: JavaScript
function SetTemplateStatus(sender) {

            if (sender.checked == true) {
                document.getElementById('<%=dtFrom.ClientId%>').disabled = false;
                document.getElementById('<%=dtTo.ClientId%>').disabled = false;
            }
            else {
                document.getElementById('<%=dtFrom.ClientId%>').disabled = true;
                document.getElementById('<%=dtTo.ClientId%>').disabled = true;
            }
          }
eo_support
Posted: Wednesday, August 19, 2009 12:04:02 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You won't be able to do that. DatePicker is not a single DHTML element that you can enable/disable on the client side. You will need to set Enabled to false from the server side. If you want to avoid full page reload, you can use a CallbackPanel or an UpdatePanel.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.