我的div在第一次执行后消失了

时间:2015-12-10 12:13:03

标签: javascript c# asp.net dependency-injection

 <link rel="Stylesheet" type="text/css" href="Styles/EIStyling.css" />
        </head>
        <body>
        <form id="BookOperator" runat="server" visible="True">  
    
            <asp:HiddenField ID="hfGlobal_UserSelectedStartBookingTime" runat="server" ></asp:HiddenField> 
            <asp:HiddenField ID="hfGlobal_UserSelectedEndBookingTime" runat="server" ></asp:HiddenField>
            <asp:HiddenField ID="hfGlobal_SelectedUserID" runat="server" ></asp:HiddenField>
            <asp:HiddenField ID="hfSelectedBookingCancelID" Value="0" runat="server" ></asp:HiddenField>
            
            <ul>
                <li class="ul" ><a href="Home.aspx" class="Mnu" >Home</a></li>
                <li class="ul" ><a class="Mnu" style="cursor:pointer" >Bookings</a>
                    <ul class="dropdown">
                        <li class="li" ><a href="BookVehicle.aspx" class="MnuItem" >Book Vehicle</a></li>
                    </ul>
                </li>
                <li class="ul" ><a class="Mnu" style="cursor:pointer" >Account </a>
                    <ul class="dropdown">
                        <li class="li" ><a href="Change_Password.aspx" class="MnuItem" >Change Password</a></li>
                        <li class="li" ><a id="LogOut" runat="server" href="LogIn.aspx" onclick="fncLogout()" class="MnuItem" >Log Out</a></li>
                    </ul>
                </li>
            </ul>

            <div class="divCalPosition">
                <asp:Calendar ID="clndrBookings" runat="server" 
                    BackColor="White" BorderColor="Black" Font-Names="Verdana" 
                    Font-Size="8pt" ForeColor="Black" Height="180px" 
                    onselectionchanged="Calendar1_SelectionChanged" Width="230px" 
                    FirstDayOfWeek="Monday" BorderStyle="Solid" CellSpacing="1" 
                    NextPrevFormat="ShortMonth">
                    <DayHeaderStyle Font-Bold="True" Height="8pt" Font-Size="8pt" 
                        ForeColor="#333333" />
                    <DayStyle BackColor="#CCCCCC" />
                    <NextPrevStyle Font-Size="9pt" ForeColor="White" Font-Bold="True" />
                    <OtherMonthDayStyle ForeColor="#CC9966" />
                    <SelectedDayStyle BackColor="#333399" ForeColor="White" />
                    <TitleStyle BackColor="#333399" 
                        Font-Bold="True" Font-Size="11pt" ForeColor="White" BorderStyle="Solid" 
                        Height="12pt" />
                    <TodayDayStyle BackColor="#999999" ForeColor="White" />
                </asp:Calendar>
            </div>

            <div id="confirmBooking" runat="server" style="display: none" align="center">

                <p class="p" >Please enter a Destination and Project Code, and
                                <br /> click "Accept" to complete booking, or press "Cancel" to return to previous screen.</p>
                  <table>
                    <tr>
                        <td><asp:Label ID="lblDestination" runat="server" CssClass="lblBook" >Destination:</asp:Label></td>
                        <td><asp:TextBox ID="txtDestination" runat="server" align="center" Width="230px" ></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td><asp:Label ID="lblProjCode" runat="server" CssClass="lblBook" >Project Code:</asp:Label></td>
                        <td><asp:TextBox ID="txtProjCode" runat="server" align="center" Width="230px" ></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnCstm" runat="server" align="center" onclick="btnCstm_Click" 
                                Text="Custom Booking" Width="110px" />  &nbsp
                            <asp:Button ID="btnMkeBook" runat="server" align="center" OnClientClick="return invalidInfo(this)" onclick="btnMkeBook_Click" 
                                Text="Accept" Width="80px" />  &nbsp
                            <asp:Button ID="btnCancel" runat="server" align="center" onclick="btnCancel_Click" 
                                Text="Cancel" Width="80px" />
                        </td>
                    </tr>
                  </table>
            </div>
                         <!--Invalid Date Modal -->
            <div class="modal fade" id="InvalidDateModal" role="dialog" style="display:none;">
            <div class="modal-dialog">
                        <!-- Modal content-->
            <div class="modal-content">
            <div class="modal-header">
                        <%--<button type="button" class="close" data-dismiss="modal">&times;</button>--%>
                <h4 class="modal-title">Warning!</h4>
            </div>
            <div class="modal-body">
                 <p> End date cannot be less than Start date.</p>
            </div>
            <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </div>
            </div>
            </div>
                        <!--Invalid Custom Info Modal -->
            <div class="modal fade" id="InvalidCusInfoModal" role="dialog" style="display:none;">
            <div class="modal-dialog">
                        <!-- Modal content-->
            <div class="modal-header">
                 <h4 class="modal-title">Warning!</h4>
            </div>

            <div class="modal-body">
                 <p> Destination and Project Code fields cannot be left empty! Make sure all information is filled out properly. </p>
            </div>
            <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </div>
            </div>
                        <!--Invalid Info Modal -->
            <div class="modal fade" id="InvalidInfoModal" role="dialog" style="display:none;">
            <div class="modal-dialog">
                        <!-- Modal content-->
            <div class="modal-header">
                 <h4 class="modal-title">Warning!</h4>
            </div>

            <div class="modal-body">
                 <p> Destination and Project Code fields cannot be left empty! Make sure all information is filled out properly. </p>
            </div>
            <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </div>

            </div>
                        <!--Invalid Missing Date Modal -->
            <div class="modal fade" id="MissingDateModal" role="dialog" style="display:none;">
            <div class="modal-dialog">
                        <!-- Modal content-->
            <div class="modal-content">
            <div class="modal-header">
                        <%--<button type="button" class="close" data-dismiss="modal">&times;</button>--%>
                <h4 class="modal-title">Warning!</h4>
            </div>
            <div class="modal-body">
                 <p> End date cannot be left empty! Make sure all information is filled out properly.</p>
            </div>
            <div class="modal-footer">
                 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
            </div>
            </div>
            </div>

            <div id="cnclOrEditBooking" runat="server" style="display:none;" align="center" onclick="lblOnClickEvent_Click">
                <p class="p" align="center" >Would you like to Delete or Edit your booking?</p>
                       
                <asp:Button id="btnUpdateBooking" align="center" runat="server" Text="Edit Booking" OnClick="btnUpdateBooking_Click"  Width="100px" />  &nbsp
                <asp:Button id="btnDelBooking" align="center" runat="server" Text="Delete Booking" Width="102px" OnClick="btnDelBooking_Click" />  &nbsp   
                <asp:Button id="btnEditBack" align="center" runat="server" Text="Back" OnClick="btnCancel_Click"  Width="100px" />
                    
            </div>

            <div id="divBookingCnclCnfrm" runat="server" style="display:none;" align="center" >
                <p class="p" align="center" > Are you sure you want to delete your booking?</p>

                <asp:Button id="btnYes" align="center" runat="server" Text="Yes" OnClick="btnYes_Click" Width="50px" /> &nbsp
                <asp:Button ID="btnNo" align="center" runat="server" Text="No" OnClick="btnNo_Click" Width="50px" />
            </div>

            <div id="CustomBooking" runat="server" style="display:block;" align="center" >
             
                     <p class="p" >PLEASE NOTE THAT CUSTOM BOOKING ONLY APPLIES FOR FULL DAY (08:00 - 17:00) BOOKINGS! <br />
                                   <br /> Enter Destination and Project Code, <br /> and then pick the Start date and the End date, and
                                <br /> click "Accept" to complete booking, or click "Cancel" to return to previous screen.</p>

                   <table>
                    <tr>
                        <td>
                            <asp:Label ID="lblCustomDestination" runat="server" CssClass="lblBook" >Destination:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="txtCustomDestination" runat="server" align="center" Width="230px" ></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblCusProjCode" runat="server" CssClass="lblBook" >Project Code:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="txtCusProjCode" runat="server" align="center" Width="230px" ></asp:TextBox>
                        </td>
                    </tr>
                    <tr>    
                        <td>
                            <asp:Label ID="lblStartDate" runat="server" CssClass="lblBook" >Start Date:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="txtStartDate" runat="server" align="center" Width="150px" 
                                ReadOnly="True" ></asp:TextBox>
                         </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblEndDate" runat="server" CssClass="lblBook" >End Date:</asp:Label>
                        </td>
                        <td>
                            <input type="text" id="calCustomBookEndDate" size="17" runat="server" 
                                readonly="readonly" />
                        </td>  
                       
                    </tr>
                    <tr>
                        <td colspan="2">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="btnCustomBook" runat="server" align="center" 
                                OnClientClick="return invalidInfoCustom(this)" onclick="btnCustomBook_Click" 
                                Text="Accept" Width="80px" /> &nbsp
                            <asp:Button ID="btnCustomCancel" runat="server" align="center" onclick="btnCancel_Click" 
                                Text="Cancel" Width="80px" />
                        </td>
                    </tr>
                </table>
            </div>

             <div id="OpsEditBooking" runat="server" style="display:block; height:400px" align="center" >
               <table style="height: 119px"> 
                 <tr>
                     <td>
                        <asp:Label ID="lblEditDestination" runat="server" CssClass="lblBook" >Destination:</asp:Label>
                     </td>
                     <td>
                         <asp:TextBox ID="txtEditDestination" runat="server" align="center" Width="230px" ></asp:TextBox>
                    
                    </td>
                </tr>
                <tr>    
                    <td>
                        <asp:Label ID="lblEditProjCode" runat="server" CssClass="lblBook" >Project Code:</asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtEditProjCode" runat="server" align="center" Width="230px" ></asp:TextBox>
                    </td>
                </tr>
                <tr>  
                    <td>
                        <asp:Label ID="lblEditStartTime" runat="server" CssClass="lblBook" >Start Time:</asp:Label>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlStartTimes" runat="server" AutoPostBack="True" 
                            onselectedindexchanged="ddlStartTimes_SelectedIndexChanged" >
                                <asp:ListItem>08:00</asp:ListItem>
                                <asp:ListItem>08:30</asp:ListItem>
                                <asp:ListItem>09:00</asp:ListItem>
                                <asp:ListItem>09:30</asp:ListItem>
                                <asp:ListItem>10:00</asp:ListItem>
                                <asp:ListItem>10:30</asp:ListItem>
                                <asp:ListItem>11:00</asp:ListItem>
                                <asp:ListItem>11:30</asp:ListItem>
                                <asp:ListItem>12:00</asp:ListItem>
                                <asp:ListItem>12:30</asp:ListItem>
                                <asp:ListItem>13:00</asp:ListItem>
                                <asp:ListItem>13:30</asp:ListItem>
                                <asp:ListItem>14:00</asp:ListItem>
                                <asp:ListItem>14:30</asp:ListItem>
                                <asp:ListItem>15:00</asp:ListItem>
                                <asp:ListItem>15:30</asp:ListItem>
                                <asp:ListItem>16:00</asp:ListItem>
                                <asp:ListItem>16:30</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                 <tr>
                    <td>
                        <asp:Label ID="lblEditEndTime" runat="server" CssClass="lblBook" >End Time:</asp:Label>
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlEndTimes" runat="server" >
                            <asp:ListItem>08:30</asp:ListItem>
                            <asp:ListItem>09:00</asp:ListItem>
                            <asp:ListItem>09:30</asp:ListItem>
                            <asp:ListItem>10:00</asp:ListItem>
                            <asp:ListItem>10:30</asp:ListItem>
                            <asp:ListItem>11:00</asp:ListItem>
                            <asp:ListItem>11:30</asp:ListItem>
                            <asp:ListItem>12:00</asp:ListItem>
                            <asp:ListItem>12:30</asp:ListItem>
                            <asp:ListItem>13:00</asp:ListItem>
                            <asp:ListItem>13:30</asp:ListItem>
                            <asp:ListItem>14:00</asp:ListItem>
                            <asp:ListItem>14:30</asp:ListItem>
                            <asp:ListItem>15:00</asp:ListItem>
                            <asp:ListItem>15:30</asp:ListItem>
                            <asp:ListItem>16:00</asp:ListItem>
                            <asp:ListItem>16:30</asp:ListItem>
                            <asp:ListItem>17:00</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr> 
                <tr>
                    <td colspan="2"> 
                        <asp:Button ID="btnAcceptEdit" runat="server" align="center" 
                        OnClientClick="return invalidInfoEditBooking(this)" onclick="btnAcceptEdit_Click" 
                        Text="Accept" Width="80px" /> &nbsp
                        <asp:Button ID="btnEditCancel" runat="server" align="center" onclick="btnCancel_Click" 
                        Text="Cancel" Width="80px" />
                    </td>
                </tr>
             </table>
            </div>

            <asp:Panel ID="pnlEmpDisp" runat="server" BackColor="Transparent" ScrollBars="Auto" >   
                <div id="dvInfo" runat="server" style="display:block" >                      
                </div>
            </asp:Panel>
            <asp:Button id="btnLogOut" runat="server" onclick="btnLogOut_Click" style="display:none;" />
        </form>
    </body>
</html>

我有一个预订系统,允许您预订,删除或编辑您的预订。点击删除按钮,  带有删除确认的<div>会弹出两个按钮,是和否。如果单击是,  预订被删除,用户被重定向回主页,您可以在其中查看和进行其他预订。  这在第一次执行时效果很好,但是如果您再次预订并尝试删除它,则确认<div>,  在单击“主页”按钮并开始删除过程之前,“是”和“否”的单词根本不会出现,  然后它会显示出来。这是我的.aspx和.cs代码

</div>

 <div id="divBookingCnclCnfrm" runat="server" style="display:none;" align="center" >
 <p class="p" align="center" > Are you sure you want to deleted your booking?</p>

 <asp:Button ID="btnYes" align="center" runat="server" Text="Yes" OnClick="btnYes_Click" Width="50px" /> &nbsp
 <asp:Button ID="btnNo" align="center" runat="server" Text="No" OnClick="btnNo_Click" Width="50px" />
            
 </div>

 protected void btnDelBooking_Click(object sender, EventArgs e)
        {
            divBookingCnclCnfrm.Style["display"] = "block";
            dvInfo.Visible = false;
            VehEditBooking.Visible = false;
            BuildVechGrid();
        }

1 个答案:

答案 0 :(得分:1)

由于您使用的是服务器端控件,因此请保持简单并使用可用于控件的属性。

更改此行:

<div id="divBookingCnclCnfrm" runat="server" style="display:none;" align="center" >

<div id="divBookingCnclCnfrm" runat="server" visible="false" align="center" >

然后在删除按钮事件中写:

    protected void btnDelBooking_Click(object sender, EventArgs e)
    {
        divBookingCnclCnfrm.Visible = true;
        dvInfo.Visible = false;
        VehEditBooking.Visible = false;
        BuildVechGrid();
    }

请测试一下是否有帮助。