2013-05-03 48 views
2

我有一個模式彈出式擴展器。在面板裏面我有兩個佔位符。兩者都是可見的錯誤。當我按下一個按鈕,並有代碼 this.ModalPopupExtender1.Show(); PlaceHolder1.Visible = true; PlaceHolder2.Visible = false; 打開模式彈出。當我有這樣的代碼:模態彈出式菜單中的兩個佔位符

this.ModalPopupExtender1.Show(); 
     PlaceHolder1.Visible = false; 
     PlaceHolder2.Visible = true; 

模式彈出不打開。如何解決這個問題?我附上我的asp.net代碼:

<asp:Button ID="btnShowPopup" runat="server" style="display:none" /> 

    <asp:ModalPopupExtender 
    ID="ModalPopupExtender1" runat="server" PopupControlID="pnlpopup" 
    TargetControlID="btnShowPopup" CancelControlID="btnCancel" 
    OkControlID="btnUpdate"  BehaviorID="ModalPopupExtender1" DropShadow="true" 
    BackgroundCssClass="modalBackground"> 
    </asp:ModalPopupExtender> 

    <asp:Panel ID="pnlpopup" runat="server" BackColor="LightGray" 
     CssClass="modalPopup" Width="600px" Height="450px"> 
      <asp:PlaceHolder ID="PlaceHolder1" Visible="false" runat="server"> 


         <table class="style1"> 
          <tr> 
           <td> 
            &nbsp;</td> 
           <td> 
            &nbsp;</td> 
          </tr> 
          <tr> 
           <td> 
            Name:</td> 
           <td> 
            <asp:TextBox ID="txtName" runat="server" CssClass="textEntry"></asp:TextBox> 
         <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtThoughtName" ErrorMessage="*" ValidationGroup="r"></asp:RequiredFieldValidator> 
         </td> 
          </tr> 
          <tr> 
           <td> 
            Description:</td> 
           <td> 
            <asp:TextBox ID="txtDescription" TextMode="MultiLine" Columns="37" 
          Rows="5" runat="server" CssClass="textEntry"></asp:TextBox> 
         <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*" ControlToValidate="txtDescription" ValidationGroup="r"></asp:RequiredFieldValidator> 
         </td> 
          </tr> 
          <tr> 
           <td> 
            Date:</td> 
           <td> 
            <asp:TextBox ID="txtDate" runat="server" Width="150px"></asp:TextBox> 
         <asp:CalendarExtender 
          ID="CalendarExtender1" runat="server" TargetControlID="txtDate"> 
         </asp:CalendarExtender><asp:RequiredFieldValidator ID="RequiredFieldValidator4" 
          runat="server" ErrorMessage="*" ControlToValidate="txtDate" 
          ValidationGroup="r"></asp:RequiredFieldValidator> 
         </td> 
          </tr> 

           <td> 
            &nbsp;</td> 
           <td> 
            &nbsp;</td> 
          </tr> 
          <tr> 
           <td colspan="2"> 
           <asp:Button ID="btnUpdate" runat="server" CommandName="Update" 
          OnClick="btnUpdate_Click" Text="Create" ValidationGroup="r" Width="100px" />&nbsp;&nbsp; 
         <asp:Button ID="btnCancel" runat="server" onclick="btnCancel_Click" 
          Text="Cancel" Width="100px" /></td> 
          </tr> 
         </table> 
         </asp:PlaceHolder> 
       <asp:PlaceHolder ID="PlaceHolder2" Visible="false" runat="server"> 
       <table class="style1"> 
          <tr> 
           <td class="style6"> 
            Join a Group:</td> 
           <td> 
            <asp:DropDownList ID="DropDownList1" runat="server" 
             DataSourceID="SqlDataSource3" DataTextField="GroupName" 
             DataValueField="GroupId"> 
            </asp:DropDownList> 
            &nbsp; 
            <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Create a Group</asp:LinkButton> 
           </td> 
          </tr> 
          <tr> 
           <td class="style6"> 
            &nbsp;</td> 
           <td> 
            <asp:Button ID="btnUpdate3" runat="server" CommandName="Update" 
            Width="160px" OnClick="btnUpdate2_Click" Text="Join Group" ValidationGroup="a" /> 
            &nbsp; 
            <asp:Button ID="btnCancel3" runat="server" onclick="btnCancel2_Click" 
            Width="160px" Text="Cancel" /> 
           </td> 
          </tr> 
          <tr> 
           <td class="style6"> 
            <asp:Label ID="Label3" Visible="false" runat="server" Text="Group Name:"></asp:Label> 
           </td> 
           <td> 
            <asp:TextBox ID="txtgroupname" Visible="false" CssClass="textEntry" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtgroupname" ValidationGroup="z" runat="server" ErrorMessage="*"></asp:RequiredFieldValidator> 
           </td> 
          </tr> 
          <tr> 
           <td class="style6"> 
            &nbsp;</td> 
           <td> 
            <asp:Button ID="Button2" Visible="false" ValidationGroup="z" runat="server" 
             Width="160px" Text="Create New Group" onclick="Button2_Click" /> 
            &nbsp; 
            <asp:Button ID="Button3" Visible="false" runat="server" Width="160px" 
             Text="Cancel" onclick="Button3_Click" /> 
           </td> 
          </tr> 
         </table> 
+0

在第二種情況下'OkControlID =「btnUpdate」'沒有顯示,需要模態,可能這是問題所在。也許如果你重新設計你的導航/行動。 – Aristos 2013-05-03 23:01:47

+1

Aristo aderfe exis dikio,efxaristw! Pedevomouna 5礦石.Postare apantisi giana sou dosw tsek。謝謝你解決的問題。 – focus 2013-05-03 23:37:57

回答

0

正如我注意到上的評論,你必須建立在asp:ModalPopupExtenderOkControlID="btnUpdate",只有在第一個佔位符該控件存在。因此,當您隱藏第一個PlaceHolder時,會使模式失敗,因爲需要該按鈕才能完全正常工作。