我想在cs文件中动态生成所需要的html,这个html里有好几个table表
然后在页面上点击某个标签对应的显示某个table表(比如点击标签a,显示table1,点击标签b,显示table2,同时table1隐藏)
请问这个功能该怎么,谁能给我具体说说,最好有代码的。谢谢各位大侠
然后在页面上点击某个标签对应的显示某个table表(比如点击标签a,显示table1,点击标签b,显示table2,同时table1隐藏)
请问这个功能该怎么,谁能给我具体说说,最好有代码的。谢谢各位大侠
解决方案 »
- 包含在Repeater 里的数据如何调用Js
- IIS中应用程序池队列的问题,向sp1234等大牛求助
- 用户控件中如何用Javascript获取内容页中文本框的值
- ◆◇◆ 关于 htm 页面向 aspx 页面 post 的问题! ◆◇◆
- 求教,一个简单的http请求响应场景的编程
- 跨站点用户管理asp.net如何实现>?速度结贴,高手进!
- SmtpMail发送电子邮件出错喽!
- 如果使用了这个句子this.btnAverageMax.Click +
- 分析器错误信息: 未能加载类型“FD.SearchCar.CarHostInfo_Amend”。
- 请教把2维数组中某一行快速转换为一维数组的方法!
- ReportViewer使用出错????
- asp.net中如何把数字1,2,3......转换成中文的一,二,三.....呢?
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
function show(id)
{
var els= document.documentElement.getElementsByTagName('table');
for(var i=0; i<els.length; i++)
{
if(els[i].id.substr(2,1)==id)
{
els[i].style.display='';
}
else
{
els[i].style.display='none';
}
} }
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%= getTable() %>
</div>
<input id="Button1" type="button" value="TB1显示" onclick="show(1)"/>
<input id="Button2" type="button" value="TB2显示" onclick="show(2)" />
<input id="Button3" type="button" value="TB3显示" onclick="show(3)"/>
<input id="Button4" type="button" value="隐藏" onclick="show(0)"/>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class htmlTable : System.Web.UI.Page
{
protected string getTable()
{
string table= "<table id='tb1' style='display:none' ><tr><td>tb1.1.A</td>";
table+="<td>tb1.1.B</td><td >tb1.1.C</td></tr><tr><td>tb1.2.A</td>";
table+="<td>tb1.2.B</td><td >tb1.2.C</td></tr><tr><td>tb1.3.A</td><td>tb1.3.B</td>";
table+="<td >tb1.3.C</td></tr></table>";
table+= "<table id='tb2' style='display:none' ><tr><td>tb2.1.A</td>";
table+="<td>tb2.1.B</td><td >tb2.1.C</td></tr><tr><td>tb2.2.A</td>";
table+="<td>tb2.2.B</td><td >tb2.2.C</td></tr><tr><td>tb2.3.A</td><td>tb2.3.B</td>";
table+="<td >tb2.3.C</td></tr></table>";
table += "<table id='tb3' style='display:none' ><tr><td>tb3.1.A</td>";
table += "<td>tb3.1.B</td><td >tb3.1.C</td></tr><tr><td>tb3.2.A</td>";
table += "<td>tb3.2.B</td><td >tb3.2.C</td></tr><tr><td>tb3.3.A</td><td>tb3.3.B</td>";
table += "<td >tb3.3.C</td></tr></table>";
return table;
} protected void Page_Load(object sender, EventArgs e)
{ }
}
<html>
<head>
<script language="javascript" type="text/javascript">
function showtable(tag){
switch (tag){
case 'div1':
document.getElementById('div2').style.display='none';
document.getElementById('div1').style.display='block';
break;
case 'div2':
document.getElementById('div1').style.display='none';
document.getElementById('div2').style.display='block';
break;
}
}
</script>
</head><body>
<input type="button" id="btn1" onclick='showtable("div1")' value="show table1" />
<div id="div3" onclick='showtable("div2")' style="cursor:hand">show table2</div>
<div id="div1"><table id="table1" border="1"><tr><td colspan="2">table1</td></tr><tr><td>1111111</td><td>2222222</td></tr></table></div>
<div id="div2"><table id="table2" border="1"><tr><td colspan="2">table2</td></tr><tr><td>1111111</td><td>2222222</td></tr></table></div>
</body>
</html>