展开全部
页面 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!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>无标题页</title> </head> <body> <form id="form1" runat="server"> <div> <asp:RadioButton ID="RadioButton1" runat="server" oncheckedchanged="RadioButton1_CheckedChanged" AutoPostBack="true"/> <br /> <asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" Visible="False"></asp:TextBox> </div> </form> </body> </html> 后台 using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void RadioButton1_CheckedChanged(object sender, EventArgs e) { if (this.RadioButton1.Checked) { this.Label1.Visible = true; this.TextBox1.Visible = true; } else { this.Label1.Visible = false; this.TextBox1.Visible = false; } } } ps:注意<asp:RadioButton ID="RadioButton1" runat="server" oncheckedchanged="RadioButton1_CheckedChanged" AutoPostBack="true"/> radiobutton的autopostback属性,要设置成true
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询