我为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>
ASPX.CS CODES FOR textbox,calendar,button
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;
}
请帮我找出解决方案......
答案 0 :(得分:0)
只需在claims
中将CausesValidation
属性设置为false: -
ImageButton