Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
禁用时datepicker值为空,jquery_Jquery_Datepicker - Fatal编程技术网

禁用时datepicker值为空,jquery

禁用时datepicker值为空,jquery,jquery,datepicker,Jquery,Datepicker,我对jQuery相当陌生。我在用户控件中有一个Jquery日期选择器。我已经向日期选择器添加了一个“disable”属性。每当我保存页面(有这个usercontrol)时,disable设置为true的日期选择器都是空的。所有其他的日期采集器都保存得很好 这是我的密码 ASPX ASCX ASCX代码隐藏 Public Property Disable() As Boolean Get Return (txtDate.Disabled = True)

我对jQuery相当陌生。我在用户控件中有一个Jquery日期选择器。我已经向日期选择器添加了一个“disable”属性。每当我保存页面(有这个usercontrol)时,disable设置为true的日期选择器都是空的。所有其他的日期采集器都保存得很好

这是我的密码

ASPX

ASCX

ASCX代码隐藏

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
我的Jquery

$(文档).ready(函数(){

日期选择器({shown:'button',buttonImage:'/Images/el calendar.gif',buttonImage only:true}); $(“输入[id$=txtDate]”)掩码(“99/99/9999,{占位符:“”); //如果“Disable=true”,则禁用日期选择器 $(“输入[id$=txtDate]”)。每个(函数(){ if($($(“输入[id$=”+this.id+“])).attr(“禁用”)==“真”){ $(“输入[id$=”+this.id+“])。日期选择器(“禁用”); } else if($($(“输入[id$=”+this.id+“])).attr(“禁用”)=“假”){ $(“输入[id$=”+this.id+“])。日期选择器(“启用”); } }); }); 对不起,我不知道这里的代码如何格式化。我为混乱的代码道歉。 谁能告诉我为什么datepicker值在禁用时为空,但在其他情况下工作正常?
感谢是进步。

只是一个猜测,但尝试使用READONLY而不是DISABLED?

我认为使用READONLY属性为true也不会改变回发中的初始值

如果您坚持按只读属性使用它,您将更改get Text的覆盖 像这样

public override string Text
{
    get
    {
        if (!base.ReadOnly)
            return base.Text;

        string s = HttpContext.Current.Request.Params[this.UniqueID];
        if (s == null)
            return base.Text;
        else
        {
            base.Text = s;
            return s;
        }
    }
    set
    {
        base.Text = value;
    }
}

关于

此代码对我有效

$('input:checkbox[name=cmpltInd]').change(function () {
   if ($(this).is(':checked')) {
      $('#efctDt').attr('readonly', true).datepicker("option", "showOn", "off");
   }
   else {
      $('#efctDt').attr('readonly', false).datepicker("option", "showOn", "focus");
   }
});
if ( ($('input:checkbox[name=cmpltInd]') != "undefined") && ($('input:checkbox[name=cmpltInd]').prop("checked")== true)) {
     $('#efctDt').attr('readonly', true).datepicker("option", "showOn", "off");
 }
这是一个HTML的东西——禁用的表单字段不会通过浏览器发送到服务器;改用只读。
$('input:checkbox[name=cmpltInd]').change(function () {
   if ($(this).is(':checked')) {
      $('#efctDt').attr('readonly', true).datepicker("option", "showOn", "off");
   }
   else {
      $('#efctDt').attr('readonly', false).datepicker("option", "showOn", "focus");
   }
});
if ( ($('input:checkbox[name=cmpltInd]') != "undefined") && ($('input:checkbox[name=cmpltInd]').prop("checked")== true)) {
     $('#efctDt').attr('readonly', true).datepicker("option", "showOn", "off");
 }