2014-01-10 48 views
0

我有三个不同的单选按钮项目,名称为“注册人类型”。如何根据单选按钮选择隐藏字段集(并禁用关联的字段集的ASP.NET验证)?

根据用户选择的内容,显示了不同的字段集。我如何最有效地显示/隐藏字段集。我还需要禁用可能在隐藏字段集存在任何ASP.NET验证:

<fieldset> 
    <legend id="legend">Registration</legend> 
    <ol> 
     <li> 
      <label for="RegistrantType">Please select your registrant type:</label> 
      <br /> 
      <div id="RegistrantType"> 
       <!-- Subscriber --> 
       <input runat="server" type="radio" name="RegistrantType" id="RegistrantTypeSubscriber" value="1" /> 
       <label runat="server" for="SuspsectTypeSubscriber">Subscriber</label> 
       <fieldset runat="server" id="RegistrantTypeSubscriberFields"> 
        <legend> 
         Subscriber 
        </legend> 
        <ol> 
         <li> 
          <input runat="server" type="text" name="RegistrantSubscriberID" placeholder="Subscriber ID" /> 
         </li> 
        </ol> 
       </fieldset> 

       <!-- Promo --> 
       <input runat="server" type="radio" name="RegistrantType" id="RegistrantTypePromo" value="2" /> 
       <label for="SuspsectTypePromo">Promo Code</label> 
       <fieldset runat="server" id="RegistrantTypePromoFields"> 
        <legend> 
         Promo 
        </legend> 
        <ol> 
         <li> 
         </li> 
        </ol> 
       </fieldset> 

       <!-- New Sign Up --> 
       <input runat="server" type="radio" name="RegistrantType" id="RegistrantTypeNew Sign Up" value="3" /> 
       <label for="SuspsectTypeNew Sign Up">New Sign Up</label> 
       <fieldset runat="server" id="RegistrantTypeNew Sign UpFields"> 
        <legend> 
         New Sign Up 
        </legend> 
        <ol> 
         <li> 
          <input runat="server" type="text" name="RegistrantFirstName" id="RegistrantFirstName" placeholder="*First Name" maxlength="128" /> 
          <input runat="server" type="text" name="RegistrantLastName" id="RegistrantLastName" placeholder="*Last Name" maxlength="128" /> 
          <br /> 
          <input runat="server" type="text" name="RegistrantPhoneNumber" id="RegistrantPhoneNumber" placeholder="*Phone Number" maxlength="14"/> 
          <br /> 
          <input runat="server" type="text" name="RegistrantStreetAddress01" id="RegistrantStreetAddress01" placeholder="*Address" maxlength="128" /> 
          <input runat="server" type="text" name="RegistrantStreetAddress02" id="RegistrantStreetAddress02" placeholder="Address" maxlength="128"/> 
          <br /> 
          <input runat="server" type="text" name="RegistrantCity" id="RegistrantCity" placeholder="*City" maxlength="128" /> 
          <asp:dropdownlist runat="server" id="RegistrantState"></asp:dropdownlist> 
          <input runat="server" type="text" name="RegistrantZIP" id="RegistrantZIP" placeholder="*ZIP Code" maxlength="10" /> 
         </li> 
        </ol> 
       </fieldset> 
      </div> 
     </li> 
        <!-- Rest of form removed for brevity... --> 
    </ol> 
</fieldset> 
+0

可能重复http://stackoverflow.com/questions/13759886/how-to-show-and-hide-fieldset-on-click-of-the-legend and http://stackoverflow.com/questions/12194054/show-hide-a-fieldset-using-jquery –

+0

第二个网址似乎有一些信息可能会将我切换到切换可见性的正确路径。但似乎没有提及任何有关停用特定验证的事情。 – user2121236

回答

2

你可以操纵领域将是这样的:

<fieldset id="fs1" runat="server"> 
    I'm one 
</fieldset> 

<fieldset id="fs2" runat="server"> 
    I'm two 
</fieldset> 

// in the code behind 
fs1.Visible = true; 
fs2.Visible = false; 
相关问题