2013-08-07 222 views
0

我有一個面板,我已經擴展與可摺疊擴展。它正在工作完美,直到我試圖通過代碼摺疊它。collapsible面板崩潰代碼不崩潰

可摺疊面板顯示在用戶搜索某些數據的模式彈出窗口內,即網格中顯示的 。在每一行網格中都有一個選擇按鈕,用於觸發網格的行命令事件,我正試圖關閉面板。

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(); 
       } 
      } 

它不工作面板總是打開?任何建議.....

+0

我想通了這條線是想念CollapsiblePanelExtender1.ClientState = 「真」;那完成了這個把戲 – ankur

回答

-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> 

希望它可以解決你的問題