【问题标题】:ajax calendar control not resetajax 日历控件未重置
【发布时间】:2013-12-19 08:43:46
【问题描述】:

我的表单中使用了一个 ajax 日历控件,用于显示日期和日期。

它的问题是,如果我选择上一年的日期并单击重置按钮,包含日期的文本框将被清除,但现在当焦点设置在文本框上时,日历控件显示之前选择的年份中的月份。

有什么方法可以在单击重置按钮时重置日历控件?

function Reset(divs) {
    $(".ui-tooltip-content").parents('div').remove();
    ClearErrorMsg();
    $('#' + divs + ' input[type="text"]').val('');
    $('#' + divs + ' select').val('');
    $('#' + divs + ' input[type="text"]').attr({ "value": "" });

    var BrwsrType = BrowserType();

    if (BrwsrType == 'IE') {
        $('#' + divs + ' select option').each(function () {
           $("select option").removeAttr('selected');
       })
   };

   $("select").each(function (i) {
       $('select :nth-child(1)').attr('selected', 'selected')
       $('select')[i].options[0].selected = true
   });

    var txtpagesize = $get('txtPageSize');
    if (txtpagesize != null) {
        txtpagesize.value = txtpagesize.attributes["defValue"].value;
        $('#' + txtpagesize.id).attr({ "value": txtpagesize.attributes["defValue"].value });
    }

    HideDialog();
    try {
        Page_ClientValidate('');
    }
    catch (er) {
    }
    return false;
}

复位按钮调用的函数如下

  function ResetForm() {
            Reset('Search');
            $(".dropdown").each(function () {
                $('.dropdown :nth-child(1)').attr('selected', 'selected')
            });



            isValidDate($get('txtBeginDate'));
            isValidDate($get('txtEndDate'));
            HideCallOut();

            $get('txtBeginDate').defaultValue = "";
            $get('txtEndDate').defaultValue = "";
            return false;
        }

【问题讨论】:

  • 你能请一些你的代码吗??
  • 只需设置 calendarextendarid.defaultvalue="";
  • 你试过了吗?也发一下..

标签: c# asp.net ajax jquery


【解决方案1】:
<script type="text/javascript" >
   function resetcalendar()
    {

 $find("_Calendar").set_selectedDate(null);
        $("[id*=Calendar]").val("");
        $(".ajax__calendar_active").removeClass("ajax__calendar_active");
        return false;
   }
</script>

其中 _Calendar 是 Calendarextender 的 BehaviorID,Calendar 是 Calendarextender 的 ID

希望对你有帮助

快乐编码

【讨论】:

  • 我按原样使用它并且它有效,但是当我使用我的日历控件的行为 ID 而不是“_Calendar”而不是“[id*=Calendar]”时,我使用了我的控件的 ID,它不起作用。你能告诉我这是什么原因吗
  • @user3118378 有什么问题?
  • 同样在调试的时候,ie调试器报错cannot set selectedDate to null ref
  • 你能告诉我是否需要按原样使用提供的脚本或更改其中的行为id和id?
  • 请仔细检查一下,我已经测试过了,对我来说效果很好,我猜你在行为 ID 上犯了错误
猜你喜欢
  • 1970-01-01
  • 2011-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-11
  • 2011-07-02
相关资源
最近更新 更多