它可以添加在Ajax工具包日历延长“无”选项? [英] It is possible to add 'None' option in ajax toolkit calendar extender?

查看:237
本文介绍了它可以添加在Ajax工具包日历延长“无”选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< ajaxToolkit:CalendarExtender> 对象在我的网页。它把选定的日期上禁用文本框(填入在启动与今天的日期)。
我希望在日历中的无选项,该系统将做一个默认操作(比如它有今天选项)。这可能吗?我搜索这个互联网上的信息,但我找不到任何相关信息。我不知道如果我错过了什么。还是我必须实现一个单独的逻辑(如使文本框键,用户可以将其留空为无的选择)?

I have an <ajaxToolkit:CalendarExtender> object in my page. It puts the selected date on a disabled TextBox (populated at start with the today date). I would want a 'None' option in that calendar, for which the system would do a default operation (like it has the Today option). Is this possible? I searched information about this on the Internet, but I couldn't find anything relevant. I wonder if I missed something. Or do I have to implement a separate logic (like enabling the TextBox and the user could leave it blank as a 'None' selection)?

有没有提供一个无选项的日历对象,从Ajax工具包日历扩展的不同,可与asp.net使用吗?

Are there any calendar objects, different from ajax toolkit calendar extender, that can be used with asp.net that offer a 'None' option?

我仍然开了一个答案甚至认为它只是一个不(至少有一点记录)。

I am still opened for an answer even thought it's just a 'No' (at least a little documented).

推荐答案

有两种方案可供选择:第一种是添加旁边的文本框的一些html元素和处理它在JavaScript中单击事件。在此事件处理程序明确的日历扩展。这是一个code:

There are two options available: the first one is to add some html element next to textbox and handle it click event in javascript. In this event handler clear calendar extender. This is a code:

 <script type="text/javascript">
      function clearDate(extenderId) {
           $find(extenderId).set_selectedDate(null);
      }
 </script>

<asp:TextBox runat="server" ID="Date1" autocomplete="off" />
<input type="button" value="x" onclick="clearDate('<%= defaultCalendarExtender.ClientID %>')" /> 
<br />
<ajaxToolkit:CalendarExtender ID="defaultCalendarExtender" runat="server" 
    TargetControlID="Date1" />

和第二溶液 - 来调整AjaxControlToolkit项目的来源。其实,你只需要改变的客户端/ MicrosoftAjax.Extended /日历/ CalendarBehavior。pre.js 文件。低于code更换。有很多code实际上因为我懒得解释每一步的变化,一步;)
总之我有新的元素添加到日历弹出页脚重置所选日期为默认选择的值如果指定,或为null。接下来您也可以调整在 Calendar.css 文件CalendarBehavior。pre.js

And the second solution - to tweak sources of the AjaxControlToolkit project. Actually, you need to change only the Client/MicrosoftAjax.Extended/Calendar/CalendarBehavior.pre.js file. Replace it with code below. There is a lot of code actually because I'm too lazy to explain each change step-by-step ;) In brief I had add new element to calendar popup footer to reset selected date to default selected value if it was specified or to null. You may tweak also the Calendar.css file next to CalendarBehavior.pre.js

由于对巨大的答案,限制我交的JavaScript code
引擎收录链接

Due to limitation on huge answers I had post javascript code on pastebin Pastebin link

这篇关于它可以添加在Ajax工具包日历延长“无”选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆