2013-04-04 74 views
1

我有兩個單選按鈕,它們具有相同的組名。在選擇一個單選按鈕時,我想要兩個新的單選按鈕,並在選擇其他單選按鈕時,我希望兩個其他單選按鈕可見。 我想要ModalPopupExtender中的所有這些。asp.net中的modalpopup extender ajax

+0

有趣的慾望。但除非你有一個令你困擾的具體問題,否則沒有人能夠回答這個問題。 – nunespascal 2013-04-04 09:46:37

回答

0

下面是一個例子:

ASPX:

<head runat="server"> 
    <title>Modal Popup</title> 
    <style type="text/css"> 
     .modalStyle 
     { 
      background-color: Gray; 
      filter: alpha(opacity=70); 
      opacity: 0.7; 
     } 

     .panelStyle 
     { 
      width: 300px; 
      height: 180px; 
      border: 2px solid Gray; 
      background-color:White; 
     } 
    </style> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <asp:ToolkitScriptManager ID="scripManager" runat="server" /> 
    <asp:ModalPopupExtender ID="modal" CancelControlID="btnCancel" BackgroundCssClass="modalStyle" PopupControlID="popup" TargetControlID="lblPopup" runat="server" /> 
    <asp:Label ID="lblPopup" runat="server" /> 
    <asp:Panel runat="server" ID="popup" CssClass="panelStyle"> 
     <table style="width: 100%;"> 
      <tr> 
       <td> 
        <asp:RadioButton ID="rdboption1" AutoPostBack="true" OnCheckedChanged="CheckedChanged" runat="server" Text="Option 1" GroupName="Options" /><br /> 
        <asp:RadioButton ID="rdboption11" runat="server" Text="Option 1.1" GroupName="SubOption1" 
         Visible="false" /><br /> 
        <asp:RadioButton ID="rdboption12" runat="server" Text="Option 1.2" GroupName="SubOption1" 
         Visible="false" /> 
       </td> 
      </tr> 
      <tr> 
       <td> 
        <asp:RadioButton ID="rdboption2" AutoPostBack="true" OnCheckedChanged="CheckedChanged" runat="server" Text="Option 2" GroupName="Options" /><br /> 
        <asp:RadioButton ID="rdboption21" runat="server" Text="Option 2.1" GroupName="SubOption2" 
         Visible="false" /><br /> 
        <asp:RadioButton ID="rdboption22" runat="server" Text="Option 2.2" GroupName="SubOption2" 
         Visible="false" /> 
       </td> 
      </tr> 
      <tr> 
       <td style="text-align: center;"> 
        <asp:Button ID="btnCancel" runat="server" Text="Cancel" /> 
       </td> 
      </tr> 
     </table> 
    </asp:Panel> 
    </form> 
</body> 

後面的代碼:

public partial class Test : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     modal.Show(); 
    } 

    protected void CheckedChanged(object sender, EventArgs e) 
    { 
     var radioButton = sender as RadioButton; 
     ResetOptions(); 
     switch(radioButton.ID) 
     { 
      case "rdboption1": 
       rdboption11.Visible = true; 
       rdboption12.Visible = true; 
       break; 
      case "rdboption2": 
       rdboption21.Visible = true; 
       rdboption22.Visible = true; 
       break; 
     } 
    } 

    private void ResetOptions() 
    { 
     rdboption11.Visible = false; 
     rdboption12.Visible = false; 
     rdboption21.Visible = false; 
     rdboption22.Visible = false; 
    } 
} 
+0

感謝@Deni在上面工作,一旦完成就會讓你知道。非常感謝 – Passenger 2013-04-04 12:22:15

相關問題