asp.net - 获取ajax日历扩展器控件的选定日期

标签 asp.net ajax asp.net-ajax ajaxcontroltoolkit

我在我的 asp.net 3.5 应用程序中使用了 Ajax 日历扩展器控件(来自 here )。

我的问题:如何从代码隐藏文件中的 Ajax 日历扩展器控件获取所选日期?

例如,我从日历中选择 01/01/2011,那么我需要在代码后面添加此日期,因为我需要检查空值。

如有任何疑问,请告诉我。

请指导。谢谢!

已使用代码更新问题

 &nbsp; <asp:Label ID="lblStartDate" runat="server" Text="<%$ Resources:Resource, lblStartDate %>" CssClass="boldlabelText"></asp:Label>
                                        &nbsp;<asp:TextBox ID="txtStartDate" runat="server" ReadOnly="true" MaxLength="10"></asp:TextBox>
                                        <asp:ImageButton runat="Server" ID="imgStartDate" ImageUrl="~/Images/Calender.png" AlternateText="Click to show calendar" />
                                        <ajax:CalendarExtender ID="CalStartDate" runat="server" TargetControlID="txtStartDate" Format="yyyy-MM-dd" PopupButtonID="imgStartDate">
                                        </ajax:CalendarExtender>

隐藏代码 (.cs)

if (txtStartDate.Text.Equals(string.Empty))  // The text value always comes null
        {
            lblStartDateM.Visible = true; 
            txtStartDate.BackColor = Color.FromArgb(255, 255, 235);
            blnIsValid = false;
        }

最佳答案

不要在 TextBox 上设置属性 ReadOnly="true"

来自Joteke's Blog

If TextBox's ReadOnly property is "true", postback data won't be loaded e.g it essentially means TextBox being readonly from server-side standpoint (client-side changes will be ignored). If you want TB to be readonly in the "old manner" use

TextBox1.Attributes.Add("readonly","readonly") 

as that won't affect server-side functionality.

关于asp.net - 获取ajax日历扩展器控件的选定日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7315376/

相关文章:

jquery - 如何在 select2 新/删除标签事件上触发新的 ajax?

node.js - 尝试使用普通 JS 发送请求 GET 来表达时,响应为空

ajax - 在服务器和客户端之间共享 mustache/mustache 模板。 ASP.NET MVC

javascript - 浏览器不显示文件已下载

jquery - 试图让最右边的 div 仅使用 CSS 对齐到底部

javascript - 从 Jquery 表单发布数据

java - ClickOnce 与 Java WebStart

c# - config.DataServiceBehavior.MaxProtocolVersion 从 V3.0 到 V2.0 的更改无法恢复

asp.net - Microsoft JScript 运行时错误 : 'Sys' is undefined

javascript - 选择下拉值时 UpdatePanel 不工作