本文介绍了单击图像按钮时不显示Aspcalendar,并且此字段也会出现错误填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在asp.net项目中有一个带有imagebutton和AspCalendar控件的输入类型文本字段。当我单击图像按钮时,页面加载事件中的日历可见性为false,并且还会在日历控件之间从上到下收到错误填写必填字段。
我尝试过:
Html代码:
I have a input type text field with imagebutton and AspCalendar controls in an asp.net project. When i am clicking the image button then the calendar visibility false in pageload event and also getting the error "Fill out required fields" from top to bottom in between calendar controls appears.
What I have tried:
Html Code:
<%-- Start Date --%>
<div class="form-group row">
<label for="inputTxtStartDate" class="col-sm-2 col-form-label">Start Date</label>
<div class="col-10">
<input type="text" id="inputTxtStartDate" name="inputTxtStartDate" class="form-control-sm" runat="server" />
<asp:ImageButton ID="imgBtnStartDateCalendar" runat="server" ImageUrl="~/Images/Calendar.ico" Width="20px" OnClick="imgBtnStartDateCalendar_Click" CausesValidation="false" />
<asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" NextPrevFormat="FullMonth" SelectionMode="DayWeekMonth" SelectMonthText="Month" SelectWeekText="Week" ForeColor="WhiteSmoke" DayNameFormat="Full" Font-Names="Book Antiqua" Font-Size="XX-Small">
<DayHeaderStyle BackColor="DarkOliveGreen" />
<DayStyle BackColor="DarkKhaki" BorderColor="Khaki" BorderWidth="1" Font-Bold="true" Font-Italic="true" />
<NextPrevStyle Font-Italic="true" Font-Names="Arial CE" />
<OtherMonthDayStyle BackColor="SeaGreen" BorderColor="DarkSeaGreen" />
<SelectedDayStyle BackColor="Green" BorderColor="SpringGreen" />
<SelectorStyle BackColor="DarkOliveGreen" ForeColor="Snow" Font-Names="Times New Roman Greek" Font-Size="Small" BorderColor="Olive" BorderWidth="1" />
<TitleStyle BackColor="DarkGreen" Height="35" Font-Size="XX-Small" Font-Names="Courier New Baltic" />
</asp:Calendar>
</div>
</div>
代码背后:
PageLoad事件:
Code Behind:
PageLoad Event:
Calendar1.Visible = false;
ImageButton Click事件:
ImageButton Click Event:
if (Calendar1.Visible == true)
Calendar1.Visible = false;
else
Calendar1.Visible = true;
推荐答案
这篇关于单击图像按钮时不显示Aspcalendar,并且此字段也会出现错误填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!