1

我有一个模态弹出扩展器。在面板内,我有两个占位符。两者都是可见的错误。当我按下按钮并 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>
4

1 回答 1

0

正如我在评论中指出的那样,您已经设置了OkControlID="btnUpdate"该控件,asp:ModalPopupExtender并且该控件仅存在于第一个 PlaceHolder 上。因此,当您隐藏第一个 PlaceHolder 时,您会使模式失败,因为需要该按钮才能完全发挥作用。

于 2013-05-03T23:44:37.157 回答