【发布时间】:2011-11-11 00:53:45
【问题描述】:
我在我的 asp.net 3.5 应用程序中使用了 Ajax 日历扩展器控件(来自 here)。
我的问题:如何从代码隐藏文件中的 Ajax 日历扩展器控件中获取选定的日期?
例如,我从日历中选择 01/01/2011,那么我需要在后面的代码中使用这个日期,因为我需要检查空值。
如有任何疑问,请告诉我。
请指导。谢谢!
问题已用代码更新
<asp:Label ID="lblStartDate" runat="server" Text="<%$ Resources:Resource, lblStartDate %>" CssClass="boldlabelText"></asp:Label>
<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;
}
【问题讨论】:
标签: asp.net ajax asp.net-ajax ajaxcontroltoolkit