collapsiblepanel崩溃代码不崩溃

时间:2013-08-07 12:21:55

标签: asp.net asp.net-ajax

我有一个用可折叠扩展器扩展的面板。它完美地工作,直到我尝试通过代码折叠它。

可折叠面板显示在模态弹出窗口内,用户搜索某些数据,即 在网格中显示,在每一行网格中都有一个选择按钮,用于触发网格的行命令事件,我试图关闭该面板。

Markup:
 <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnAdd"
        PopupControlID="pnlpopup" CancelControlID="Cancel" BackgroundCssClass="modalBackground">
    </asp:ModalPopupExtender>
    <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="320px" Width="530px"
        Style="display: none">
        <table width="100%" style="border: Solid 3px #D55500; height: 100%" cellpadding="0"
            cellspacing="0">
            <tr>
                <td>
                    Bridge ID :
                    <asp:TextBox ID="txtID" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvID" runat="server" ControlToValidate="txtID" ValidationGroup="vldAddBridge"
                        ErrorMessage="Please enter ID" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
                <td>
                    Bridge Name :
                    <asp:TextBox ID="txtBridgeName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvBridgeName" runat="server" ControlToValidate="txtBridgeName"
                        ValidationGroup="vldAddBridge" ErrorMessage="Please enter bridge name." ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>

                                <td colspan="2" style="text-align: right; margin-left: 40px;">
                                    <asp:Button ID="btnSearchUser" runat="server" OnClick="btnSearchUser_Click" TabIndex="5"
                                        Text="Search" ValidationGroup="vgSearchMember" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="5" style="background-color: White" class="style6">
                                    <asp:Label ID="lblSearchResults" runat="server"></asp:Label>
                                    <asp:GridView ID="gvSearchResults" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                        BackColor="White" BorderWidth="1px" CellPadding="4" CssClass="gridviewBorder"
                                        DataKeyNames="EmpId" ForeColor="Black" GridLines="Horizontal" PageSize="5" RowStyle-CssClass="style5"
                                        TabIndex="7" Width="100%" OnPageIndexChanging="gvSearchResults_PageIndexChanging"
                                        OnRowCommand="gvSearchResults_RowCommand">
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkSelect" runat="server" Text="Select" CommandName="Select"
                                                        CommandArgument='<%# Eval("EmpId") %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="EmpId" HeaderText="Employee ID" />
                                            <asp:BoundField DataField="Alias" HeaderText="Username" />
                                            <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                            <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                        </Columns>

                                    </asp:GridView>
                                    <br />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" CollapseControlID="btnOwner"
                        ExpandControlID="btnOwner" TargetControlID="PnlRegister" Collapsed="true">
                    </asp:CollapsiblePanelExtender>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <br />
                    <asp:Button ID="btnSaveBridge" runat="server" Text="Save" OnClick="btnSaveBridge_Click"
                        ValidationGroup="vldAddBridge" />
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
                    <span style="display: none">
                        <input type="button" id="Cancel" /></span>
                </td>
            </tr>
        </table>
    </asp:Panel>




    Code:
     protected void gvSearchResults_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "Select")
                {
                     //some business logic
                    CollapsiblePanelExtender1.Collapsed = true;
                    ModalPopupExtender1.Show();
                }
            }

它不工作面板总是打开?任何建议......

1 个答案:

答案 0 :(得分:-1)

你错过了

  • tr在你的设计中。请检查

标记:

<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnAdd"
        PopupControlID="pnlpopup" CancelControlID="Cancel" BackgroundCssClass="modalBackground">
    </asp:ModalPopupExtender>
    <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="320px" Width="530px"
        Style="display: none">
        <table width="100%" style="border: Solid 3px #D55500; height: 100%" cellpadding="0"
            cellspacing="0">
            <tr>
                <td>
                    Bridge ID :
                    <asp:TextBox ID="txtID" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvID" runat="server" ControlToValidate="txtID" ValidationGroup="vldAddBridge"
                        ErrorMessage="Please enter ID" ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
                <td>
                    Bridge Name :
                    <asp:TextBox ID="txtBridgeName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="rfvBridgeName" runat="server" ControlToValidate="txtBridgeName"
                        ValidationGroup="vldAddBridge" ErrorMessage="Please enter bridge name." ForeColor="Red"></asp:RequiredFieldValidator>
                </td>
            </tr>
            **<tr> //This is missing**
                                <td colspan="2" style="text-align: right; margin-left: 40px;">
                                    <asp:Button ID="btnSearchUser" runat="server" OnClick="btnSearchUser_Click" TabIndex="5"
                                        Text="Search" ValidationGroup="vgSearchMember" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="5" style="background-color: White" class="style6">
                                    <asp:Label ID="lblSearchResults" runat="server"></asp:Label>
                                    <asp:GridView ID="gvSearchResults" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                        BackColor="White" BorderWidth="1px" CellPadding="4" CssClass="gridviewBorder"
                                        DataKeyNames="EmpId" ForeColor="Black" GridLines="Horizontal" PageSize="5" RowStyle-CssClass="style5"
                                        TabIndex="7" Width="100%" OnPageIndexChanging="gvSearchResults_PageIndexChanging"
                                        OnRowCommand="gvSearchResults_RowCommand">
                                        <Columns>
                                            <asp:TemplateField>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lnkSelect" runat="server" Text="Select" CommandName="Select"
                                                        CommandArgument='<%# Eval("EmpId") %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="EmpId" HeaderText="Employee ID" />
                                            <asp:BoundField DataField="Alias" HeaderText="Username" />
                                            <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                                            <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                                        </Columns>

                                    </asp:GridView>
                                    <br />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                    <asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" CollapseControlID="btnOwner"
                        ExpandControlID="btnOwner" TargetControlID="PnlRegister" Collapsed="true">
                    </asp:CollapsiblePanelExtender>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <br />
                    <asp:Button ID="btnSaveBridge" runat="server" Text="Save" OnClick="btnSaveBridge_Click"
                        ValidationGroup="vldAddBridge" />
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" />
                    <span style="display: none">
                        <input type="button" id="Cancel" /></span>
                </td>
            </tr>
        </table>
    </asp:Panel>

希望它能解决你的问题