ASP.NET C#结合,做了两个单选按钮RadioButton,有两个Label控件,一个TEXTBOX

其中点击RadioButton1时,两个Label控件,一个TEXTBOX可见,否则不可见,我的代码是protectedvoidPage_Load(objectsende... 其中点击RadioButton1时,两个Label控件,一个TEXTBOX可见,否则不可见,我的代码是

protected void Page_Load(object sender, EventArgs e)
{ if (RadioButton2.Checked)
{
Label8.Visible = true;
Label13.Visible = true;
TextBox7.Visible = true;
Response.Write(@"<script>alert('吖!')</script>");

else
{

Label8.Visible = false;
Label13.Visible = false;
TextBox7.Visible = false;
}
}

这样做没错,可是一直显示不出来,为什么?
我想在页面一点击RadioButton就出现,不用BUTTON按钮
展开
 我来答
123456leo
2010-05-08 · TA获得超过553个赞
知道小有建树答主
回答量:294
采纳率:0%
帮助的人:229万
展开全部
页面
<%@ 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
wushuo945
2010-05-07 · TA获得超过468个赞
知道答主
回答量:58
采纳率:0%
帮助的人:0
展开全部
你点单选按钮后要回发到服务器才能生效,
你也可以写在按钮的单击事件里面,
我写的没问题
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked)
{
TextBox1.Visible = false;
}
else
{
TextBox1.Visible = true;
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
安靜de我
2010-05-07 · TA获得超过215个赞
知道小有建树答主
回答量:99
采纳率:0%
帮助的人:39.1万
展开全部
RadioButton2.Checked=true;吧
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
墨秋梵光03r
2010-05-07 · TA获得超过156个赞
知道小有建树答主
回答量:163
采纳率:0%
帮助的人:212万
展开全部
if (RadioButton2.Checked)这个条件没有满足
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式