views:

98

answers:

1

Hi. I'm fairly new to jQuery. I have a Jquery datepicker in a user control. I have added a "disable" property to the datepicker. Whenever I save the page(having this usercontrol) the datepicker with disable set to true is empty. All other datepickers save fine.

Here is my code.

ASPX

< USERCONTROL:DATEPICKER id="dpBirthDate" startyear="1980" runat="server" Disable=true>

ASCX < input type="text" size="8" runat="server" id="txtDate" name="txtDate" onblur="ValidateForm(this.id);" />

ASCX Code Behind

Public Property Disable() As Boolean
        Get
           Return (txtDate.Disabled = True)
        End Get
        Set(ByVal bValue As Boolean)

            If (bValue = True) Then
                txtDate.Attributes.Add("Disabled", "True")
            Else
                txtDate.Attributes.Remove("Disabled")
            End If

        End Set


    End Property

My Jquery

$(document).ready(function() {

    $("input[id$=txtDate]").datepicker({ showOn: 'button', buttonImage: '<%=ConfigurationSettings.AppSettings("BASE_DIRECTORY")%>/Images/el-calendar.gif', buttonImageOnly: true });
    $("input[id$=txtDate]").mask("99/99/9999", { placeholder: " " });


    //Disable datepicker if "disable=true"
    $("input[id$=txtDate]").each(function() {

    if ($("input[id$=" + this.id + "]").attr("Disabled") == "True") {          
            $("input[id$=" + this.id + "]").datepicker("disable");               
        }
        else if ($("input[id$=" + this.id + "]").attr("Disabled") == "False") {
            $("input[id$=" + this.id + "]").datepicker("enable");
        }

    });


});

I am sorry, I am not sure how to format the code here. I apologies for the cluttered code. Can anybody tell me why the datepicker value is empty when it is disabled but works fine otherwise? Thanks is advance.

+1  A: 

Just a guess, but try using READONLY instead of DISABLED?

Andrew M. Andrews III