prkash
prkash

Reputation: 449

Asp button disables the month change on asp calendar

I have an asp calendar which works fin normally but when I add a asp button to submit the the textbox values in form the calendar only shows current month the previous and next month buttons doesn't work.

<form id="form1" runat="server">
    <div>
        <asp:Calendar ID="cal2" runat="server" Width="50%" DayField="Date" OnDayRender="Calendar1_DayRender"
            BackColor="Orange" NextMonthText="Next" PrevMonthText="Prev" OnVisibleMonthChanged="Calendar1_VisibleMonthChanged" >
            <DayStyle CssClass="days" VerticalAlign="Top" Font-Name="Arial" Width="100px" Height="100px" BackColor="lightYellow"  />
             <TodayDayStyle BackColor="Orange"  />
            <OtherMonthDayStyle BackColor="LightGray" ForeColor="DarkGray"/>
        </asp:Calendar>
        </div>
    <asp:Button ID="submit" CssClass="login" runat="server" Text="Submit" OnClick="Submit_click" /> 
</form>

I have some textboxes which I have post back to the server side and for that I need to use the asp button, how can I prevent it from disabling the calendar functions? Thanks in advance

Upvotes: 0

Views: 276

Answers (1)

Paul-Jan
Paul-Jan

Reputation: 17278

The problem is with the name (ID) of your button. The Calender component uses an internal (javascript) call to form.submit(), introducing a button with this ID breaks that call.

Example fix:

<asp:Button ID="MySubmit" CssClass="login" runat="server" Text="Submit" OnClick="Submit_click" />

(This is not unique to the Calendar component, in general you should not name your buttons "submit" in ASP.NET unless you know exactly what you are doing)

Upvotes: 2

Related Questions