Click here to Skip to main content
15,886,078 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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>


Code Behind:

PageLoad Event:
Calendar1.Visible = false;


ImageButton Click Event:
if (Calendar1.Visible == true)
    Calendar1.Visible = false;
else
    Calendar1.Visible = true;
Posted
Updated 21-Mar-18 19:04pm

1 solution

Problem is fixed.... The solution is here is only HTML input tags..... I just deleted input tags and changed to asp textbox and fixed the problem.

Now it is firing as expected and previously i am having Updatepanel. Inside Updatepanel i am having placeholder also. Inside placeholder there is a form fields in which one of the field is imagebutton, calendar, and textbox.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900