简体   繁体   English

如何禁用日历扩展器?

[英]How to disable calendar extender?

Is it possible to disable calendar extender from code behind? 是否可以从后面的代码中禁用日历扩展器? If yes how? 如果是,怎么办? I want to prevent calendar from popping up even if a user clicks withing the textbox when certain conditions are met. 我希望即使满足特定条件的情况下用户单击文本框也不会阻止日历弹出。

I'll try doing this on the client side javascript: 我将尝试在客户端javascript上执行此操作:

  function HidePopUp() {
      document.getElementById('calenderExtender1').style.display = "none";
    }

In form load of the page you add a click event which will tri 在页面的表单加载中,添加一个click事件,该事件将

    txtDate1.Attributes.Add("OnClick", "HidePopUp()");

Hope it helps 希望能帮助到你

If you are using Jquery to create the calendar you can just remove the hasDatepicker class from the textbox: 如果使用Jquery创建日历,则可以从文本框中删除hasDatepicker类:

protected void Page_Load(object sender, EventArgs e)
{
   TextBox1.CssClass = TextBox1.CssClass.Replace("hasDatepicker", "");
}

If you dont care about being able to manually edit the date, setting 如果您不希望能够手动编辑日期,请设置

TextBox1.Enabled = false

will cause the calendar popup to not appear when you click the textbox. 当您单击文本框时,将导致日历弹出窗口不出现。
One side effect is that the textbox will appear disabled. 副作用是该文本框将显示为禁用状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM