如题 我想问下 用RadioButtonList 如何控制div的隐藏于显示
用JavaScript写的 不是写在后台的 有办法吗?
用JavaScript写的 不是写在后台的 有办法吗?
解决方案 »
- IHttpModule
- 使用swfupload上传超过2个文件就报500
- 如何在后台得到 每次页面刷新获取 地址栏信息
- excel导入SQL的问题
- vs2008中一个解决方案理有多个项目,设定启动项和起始页后调试,一下出现几个开发服务器,高手们,谢谢……
- 将参数值从 String 转换到 DateTime 失败
- MSDN等话题讨论,来者加分!
- 在ASP.net中如何禁止后退
- 紧急求助:???????net与SQLserver数据源连接不上请各位大侠指点!!!!
- dropdownlist绑定数据库的数据后在运行过程中总是成倍的显示,该怎么解决???
- 如何用Cookies保存主题信息?
- datagridview 序列号
问问题写详细点啊
{
var div=document.getElementById("div1")
div.style.display=div.style.display=="none"?"block":"none";
}
Page.RegisterStartUpScript("key",@"getElementById('div').style.display = 'none';") <div id="div1" runat="Server"> </div>
div1.Style["Display"] = "Block"; //显示
div1.Style["Display"] = "None"; //隐藏
<asp:ListItem onclick="showDivByID(1);">1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:RadioButtonList>function showDivByID(index)
{
document.getElementById("div" + index).style.display = "block";
}
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Test.WebForm1" %><!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">
<asp:RadioButtonList ID="RadioButtonList1" runat="server" onchange="showDiv();" AutoPostBack="true"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="1">第一个</asp:ListItem>
<asp:ListItem Value="2">第二个</asp:ListItem>
<asp:ListItem Value="3">第三个</asp:ListItem>
</asp:RadioButtonList>
<div id="div1" style="display:none;background-color:Gray;">
我是DIV
</div>
</form>
</body>
</html>
后台代码:
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
int i = RadioButtonList1.SelectedIndex;
if (i % 2 == 0)
{
Page.RegisterStartupScript("showDiv", "<script>document.getElementById('div1').style.display='inline';</script>");
}
else
{
Page.RegisterStartupScript("showDiv", "<script>document.getElementById('div1').style.display='none';</script>");
}
}
display="block"显示