ASP.NET手风琴和日历使得按钮点击事件不会引发

时间:2013-05-07 06:21:41

标签: asp.net calendar onclick ajaxcontroltoolkit accordion

我手风琴有3个窗格。在其中一个窗格上有一个按钮,它应该引发一个点击事件,但事实并非如此。我试图删除所有无法正常工作的验证器,删除无效的CalendarExtenders,将按钮放在手风琴外部无法正常工作,用外面的按钮注释掉手风琴,但没有用,注释掉不起作用的日历,但是当我注释掉日历和手风琴时,它会正确触发事件。我通过在正确的方法中放置一个断点来检查它是否触发,并且当它不起作用时请求也会超时。

标记如下:

<div id="container">
    <div id="calendar">
        <asp:calendar id="Calendar1" runat="server" backcolor="#6dc066" bordercolor="#000000" borderwidth="2px" font-names="Verdana" font-size="1.2em" forecolor="White" height="400px" width="400px" style="margin-right: 0px" cellpadding="4" daynameformat="Shortest" ondayrender="Calendar1_DayRender" onselectionchanged="Calendar1_SelectionChanged">
            <DayHeaderStyle BackColor="#666666" Font-Bold="True" Font-Size="9pt" />
            <NextPrevStyle VerticalAlign="Bottom" />
            <OtherMonthDayStyle ForeColor="#000000" />
            <TitleStyle BackColor="#494949" BorderColor="Black" Font-Bold="True" />
            <TodayDayStyle BackColor="#FFFFFF" ForeColor="Black" />
            <WeekendDayStyle BackColor="#487346"/>
        </asp:calendar>
    </div>
    <div class="accordion-div">
        <asp:Accordion ID="MyAccordion" runat="Server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected" ContentCssClass="accordion" TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="true" SuppressHeaderPostbacks="true">
            <Panes>
                <asp:AccordionPane runat="server" ID="InfoPane">
                    <header>Informationer om valgt dato</header>
                    <Content>
                        <div style="margin: 5px;">
                            <b>Startdato: </b><asp:Label runat="server" ID="startLabel" />
                            <br />
                            <b>Slutdato: </b><asp:Label runat="server" ID="endLabel" />
                            <br />
                            <b>Reserveret af: </b><asp:Label runat="server" ID="authorLabel" />
                            <br />
                            <b>Kommentarer: </b><asp:Label runat="server" ID="commentsLabel" />
                            <br />
                            <b>Reserveringstidspunkt: </b><asp:Label runat="server" ID="bookedTimeLabel" />
                        </div>
                    </Content>
                </asp:AccordionPane>
                <asp:AccordionPane runat="server" ID="BookingPane">
                    <Header>Reservering</Header>
                    <Content>
                        <div style="margin-left: 10px; width: 350px;">
                            <h3>Reserver:</h3>
                            <p>
                                <b>Startdato: </b><asp:TextBox runat="server" ID="txtStart" CausesValidation="true" CssClass="right-align"></asp:TextBox>
                                <asp:CalendarExtender FirstDayOfWeek="Monday" ID="txtStart_CalendarExtender" runat="server" Enabled="True" TargetControlID="txtStart" Format="dd/MM/yyyy">
                                </asp:CalendarExtender>
                                <asp:RequiredFieldValidator ID="StartRequired" ControlToValidate="txtStart" runat="server" ErrorMessage="Udfyldelse er påkrævet" Display="Dynamic"/>
                                <asp:RangeValidator ID="StartRange" ControlToValidate="txtStart" runat="server" ErrorMessage="Startdato skal være efter i dag" Type="Date" Display="Dynamic"/>
                                <br />
                            </p>
                            <p>
                                <b>Slutdato: </b><asp:TextBox runat="server" ID="txtEnd" CausesValidation="true" CssClass="right-align"></asp:TextBox>
                                <asp:CalendarExtender FirstDayOfWeek="Monday" ID="txtEnd_CalendarExtender" runat="server" Enabled="True" TargetControlID="txtEnd" Format="dd/MM/yyyy">
                                </asp:CalendarExtender>
                                <asp:RequiredFieldValidator ID="EndRequired" ControlToValidate="txtEnd" runat="server" ErrorMessage="Udfyldelse er påkrævet" Display="Dynamic"/>
                                <asp:RangeValidator ID="EndRange" ControlToValidate="txtEnd" runat="server" ErrorMessage="Slutdato skal være efter i dag" Type="Date" Display="Dynamic"/>
                                <br />
                            </p>
                            <p>
                                <b>Kommentar: </b><asp:TextBox runat="server" ID="txtComment" CssClass="right-align"></asp:TextBox>  
                                <br />
                            </p>
                            <p>
                                <asp:CustomValidator runat="server" ID="customVal" ControlToValidate="txtEnd" ErrorMessage="En af de valgte dag er booket" OnServerValidate="customVal_ServerValidate" Display="Dynamic"/>
                                <asp:CompareValidator runat="server" ControlToValidate="txtStart" ErrorMessage="Startdatoen skal være før slutdatoen" ControlToCompare="txtEnd" Operator="LessThanEqual" Type="Date" Display="Dynamic"/>
                                <br />
                                <asp:Button ID="BookButton" runat="server" OnClick="BookButton_Click" Text="Reserver" BackColor="LightGray" BorderStyle="Solid" BorderColor="Black"/>
                                <br />
                                <asp:Label runat="server" ID="SuccesLabel" Visible="false" BackColor="LightGreen"/>
                            </p>
                        </div>
                    </Content>
                </asp:AccordionPane>
                <asp:AccordionPane runat="server" ID="MyReservationPane">
                    <header>Mine reservationer</header>
                </asp:AccordionPane>
            </Panes>
        </asp:Accordion>
    </div>
</div>

提前致谢

1 个答案:

答案 0 :(得分:1)

我测试了你的代码。它表明您的日期格式不匹配。在日历扩展程序中将日期格式设置为英语,但是范围验证程序将根据美国日期格式进行评估。因此,阻止您回复按钮点击。

如果是这种情况,您可以在Page_Load(代码隐藏)中添加以下内容:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");

这可以解决您的问题。