从日历中进行选择后,值没有输入到文本框中
本文关键字:输入 文本 日历 行选 选择 | 更新日期: 2023-09-27 18:15:16
我已经为txtProjectDate文本框启用了必填字段验证器,它不允许在单击日历按钮后弹出日历。因此,无法在文本框中选择要输入的值。错误:强制性字段
ASPX文件 <tr>
<td>Project Started at</td>
<td>::</td>
<td><asp:TextBox ID="txtProjectDate" runat="server" OnTextChanged="txtProjectDate_TextChanged1"></asp:TextBox>
<asp:ImageButton ID="btnShowCalendar" runat="server" OnClick="btnShowCalendar_Click" ImageUrl="D:'calendar4.png" />
<asp:Calendar ID="calProjectDate" runat="server" OnSelectionChanged="calProjectDate_SelectionChanged" Visible="False"></asp:Calendar>
<asp:RequiredFieldValidator ID="rfvProjectDate" runat="server" ControlToValidate="txtProjectDate" ErrorMessage="MANDATORY"></asp:RequiredFieldValidator>
</td>
</tr>
文本框、日历、按钮的asp . cs代码
protected void btnShowCalendar_Click(object sender, ImageClickEventArgs e)
{
calProjectDate.Visible = true;
}
protected void calDateofBirth_SelectionChanged(object sender, EventArgs e)
{
txtProjectDate.Text = calProjectDate.SelectedDate.ToShortDateString();
calProjectDate.Visible = false;
}
protected void txtProjectDate_TextChanged(object sender, EventArgs e)
{
}
protected void calProjectDate_SelectionChanged(object sender, EventArgs e)
{
txtProjectDate.Text =
calProjectDate.SelectedDate.ToShortDateString();
calProjectDate.Visible = false;
}
将ImageButton
中的CausesValidation
属性设置为false:-
<asp:ImageButton ID="btnShowCalendar" runat="server" CausesValidation="false"
OnClick="btnShowCalendar_Click" ImageUrl="D:'calendar4.png" />