简体   繁体   English

“ asp”按钮禁用“ asp”日历上的月份更改

[英]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. 我有一个asp日历,该日历通常可以正常工作,但是当我添加一个asp按钮以提交文本框值的形式时,日历仅显示当前月份,上一个和下一个月份的按钮不起作用。

<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? 我有一些文本框已发回到服务器端,为此,我需要使用asp按钮,如何防止其禁用日历功能? Thanks in advance 提前致谢

The problem is with the name (ID) of your button. 问题出在您按钮的名称(ID)。 The Calender component uses an internal (javascript) call to form.submit(), introducing a button with this ID breaks that call. 日历组件使用内部(javascript)调用form.submit(),引入具有此ID的按钮可中断该调用。

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) (这不是Calendar组件所独有的,通常,除非您确切知道自己在做什么,否则不应在ASP.NET中将按钮命名为“ submit”)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM