模态弹出窗口内的两个占位符

时间:2013-05-03 21:22:04

标签: c# asp.net ajax

我有一个模态弹出扩展器。在面板内我有两个占位符。两者都是假的。当我按下按钮并有代码时            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>

1 个答案:

答案 0 :(得分:0)

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