日期:2014-05-18 浏览次数:20474 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True" OnCheckedChanged="RadioButton1_CheckedChanged" GroupName="1" /> <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True" OnCheckedChanged="RadioButton2_CheckedChanged" GroupName="1" /> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> </div> </form> </body> </html> cs 文件 using System; using System.Web.UI; public partial class Default3 : Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList1.Items.Add("1"); DropDownList1.Items.Add("2"); } } protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { DropDownList1.Visible = false; } protected void RadioButton2_CheckedChanged(object sender, EventArgs e) { DropDownList1.Visible = true; } } 我试过,这样不会有问题的