采用Table+CSS来实现的模拟选项卡,现在有一个十分严重的问题:窗体启动第一卡片是当前项,选中第二卡片,上面有一个LinkButton1,单击,因为是服务器控件,窗体刷新,之后当前项又变成了第一卡片,怎么样能让刷新之后当前项还是第二卡片呢?请大家看看下面的代码,其中有一个secBoard(n)函数,我在Linkbutton3_Click中这样调用这个函数:Linkbutton3.Attributes.Add("onClick","secBoard(1)");可是不行,没有作用,请大家帮我啊!谢谢 <style type=text/css>
td {
font-size: 12px;
color: #000000;
line-height: 150%;
}
.sec1 {
background-color: #EEEEEE;
cursor: hand;
color: #000000;
border-left: 1px solid #FFFFFF;
border-top: 1px solid #FFFFFF;
border-right: 1px solid gray;
border-bottom: 1px solid #FFFFFF
}
.sec2 {
background-color: #D4D0C8;
cursor: hand;
color: #000000;
border-left: 1px solid #FFFFFF;
border-top: 1px solid #FFFFFF;
border-right: 1px solid gray;
font-weight: bold;
}
.main_tab {
background-color: #D4D0C8;
color: #000000;
border-left:1px solid #FFFFFF;
border-right: 1px solid gray;
border-bottom: 1px solid gray;
}
</style>
<script language=javascript>
function secBoard(n)
{
for(i=0;i<secTable.cells.length;i++)
secTable.cells[i].className="sec1";
secTable.cells[n].className="sec2";
for(i=0;i<mainTable.tBodies.length;i++)
mainTable.tBodies[i].style.display="none";
mainTable.tBodies[n].style.display="block";
}
</script>
<table border=0 cellspacing=0 cellpadding=0 width=549 id=secTable>
<tr height=20 align=center>
<td class="sec2" onclick="secBoard(0)" width="115">工商执照</td>
<td class="sec1" onclick="secBoard(1)" width="115">电子税务</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width=549 height=240 id=mainTable class=main_tab>
<tbody style="display:block;">
<tr>
<td align=center valign=top> <br>
<br>
这里填加内容,略去。1 </td>
</tr>
</tbody> <tbody style="display:none;">
<tr>
<td align=center valign=top> <br>
<br>
<asp:LinkButton id="LinkButton1" runat="server" ForeColor="Red">
</td>
</tr>
</tbody>
</table>
td {
font-size: 12px;
color: #000000;
line-height: 150%;
}
.sec1 {
background-color: #EEEEEE;
cursor: hand;
color: #000000;
border-left: 1px solid #FFFFFF;
border-top: 1px solid #FFFFFF;
border-right: 1px solid gray;
border-bottom: 1px solid #FFFFFF
}
.sec2 {
background-color: #D4D0C8;
cursor: hand;
color: #000000;
border-left: 1px solid #FFFFFF;
border-top: 1px solid #FFFFFF;
border-right: 1px solid gray;
font-weight: bold;
}
.main_tab {
background-color: #D4D0C8;
color: #000000;
border-left:1px solid #FFFFFF;
border-right: 1px solid gray;
border-bottom: 1px solid gray;
}
</style>
<script language=javascript>
function secBoard(n)
{
for(i=0;i<secTable.cells.length;i++)
secTable.cells[i].className="sec1";
secTable.cells[n].className="sec2";
for(i=0;i<mainTable.tBodies.length;i++)
mainTable.tBodies[i].style.display="none";
mainTable.tBodies[n].style.display="block";
}
</script>
<table border=0 cellspacing=0 cellpadding=0 width=549 id=secTable>
<tr height=20 align=center>
<td class="sec2" onclick="secBoard(0)" width="115">工商执照</td>
<td class="sec1" onclick="secBoard(1)" width="115">电子税务</td>
</tr>
</table>
<table border=0 cellspacing=0 cellpadding=0 width=549 height=240 id=mainTable class=main_tab>
<tbody style="display:block;">
<tr>
<td align=center valign=top> <br>
<br>
这里填加内容,略去。1 </td>
</tr>
</tbody> <tbody style="display:none;">
<tr>
<td align=center valign=top> <br>
<br>
<asp:LinkButton id="LinkButton1" runat="server" ForeColor="Red">
</td>
</tr>
</tbody>
</table>
解决方案 »
- 关于C#的引用&值传递弱弱的问几句.
- 我把一些服务器控件的ID存储在一个string[]数组当中,现在想将这些控件全部禁用,应该怎么写?
- 如何将数据倒入到SqlServer 数据库???
- 用ASP做论坛
- 请问以WEB启动的smartclien里,能否取到所在页面的cookie值?
- 通过Asp.net如何获取一个网络的连接速度?
- 直接把js加在文件中和用ResgistScriptBlock有什么不同
- 后台拼写 Jquyer 报错 $未定义
- 关于自定义查询和打印的一些问题
- 试用强类型数据集重写DAL,发现一旦使用Dataset.xsd,原有的方法都不起作用了,排除Dataset.xsd后就能用。
- |M| 麻烦幕白兄,还是上次那个打印控件的问题:如何设置我那个控件的打印高度和宽度
- 使用了母板的内容页怎样动态创建自定义用户控件?
<head>
<title>滑动菜单</title>
</head>
<style>
body {font-size:12px;font-family:宋体}
ul.TabBarLevel1{
list-style:none;
margin:0;
padding:0;
height:29px;
background-image:url(tabbar_level1_bk.gif);
}
ul.TabBarLevel1 li{
float:left;
padding:0;
height:29px;
margin-right:1px;
background:url(tabbar_level1_slice_left_bk.gif) left top no-repeat;
}
ul.TabBarLevel1 li a{
display:block;
line-height:29px;
padding:0 20px;
color:#333;
background:url(tabbar_level1_slice_right_bk.gif) right top no-repeat;
white-space: nowrap;
}
ul.TabBarLevel1 li.Selected{
background:url(tabbar_level1_slice_selected_left_bk.gif) left top no-repeat;
}
ul.TabBarLevel1 li.Selected a{
background:url(tabbar_level1_slice_selected_right_bk.gif) right top no-repeat;
}ul.TabBarLevel1 li a:link,ul.TabBarLevel1 li a:visited{
color:#333;
}
ul.TabBarLevel1 li a:hover,ul.TabBarLevel1 li a:active{
color:#F30;
text-decoration:none;
}
ul.TabBarLevel1 li.Selected a:link,ul.TabBarLevel1 li.Selected a:visited{
color:#000;
}
ul.TabBarLevel1 li.Selected a:hover,ul.TabBarLevel1 li.Selected a:active{
color:#F30;
text-decoration:none;
}
div.HackBox {
padding : 2px 2px ;
border-left: 2px solid #6697CD;
border-right: 2px solid #6697CD;
border-bottom: 2px solid #6697CD;
display:none;
}
</style>
<body>
<div id="Whatever">
<ul class="TabBarLevel1" id="TabPage1">
<li id="Tab1"><a href="#" onclick="javascript:switchTab('TabPage1','Tab1');">单道试题</a></li>
<li id="Tab2" class="Selected"><a href="#" onclick="javascript:switchTab('TabPage1','Tab2');">多道试题</a></li>
<li id="Tab3"><a href="#" onclick="javascript:switchTab('TabPage1','Tab3');">成套试题</a></li>
<li id="Tab4"><a href="#" onclick="javascript:switchTab('TabPage1','Tab4');">留言簿</a></li>
</ul>
<div id="cnt">
<div id="dTab1" class="HackBox">代码如下:
请输入单道试题
</div>
<div id="dTab2" class="HackBox" style="display:block">代码如下:
<!--这里放入信息-->
哈哈哈哈2
</div>
<div id="dTab3" class="HackBox">代码如下:
<!--这里放入信息-->
哈哈哈哈3
</div>
<div id="dTab4" class="HackBox">代码如下:
<!--这里放入信息-->
哈哈哈哈4
</div>
</div>
</div>
<script language="JavaScript">
//Switch Tab Effect
function switchTab(tabpage,tabid){
var oItem = document.getElementById(tabpage);
for(var i=0;i<oItem.children.length;i++){
var x = oItem.children(i);
x.className = "";
var y = x.getElementsByTagName('a');
y[0].style.color="#333333";
}
document.getElementById(tabid).className = "Selected";
var dvs=document.getElementById("cnt").getElementsByTagName("div");
for (var i=0;i<dvs.length;i++){
if (dvs[i].id==('d'+tabid))
dvs[i].style.display='block';
else
dvs[i].style.display='none';
}
}
</script>
</body>
</html>
加一句
Form1.hidIndex.Value = n; //页面上放个hidden
function window.onload)(
{
if(Form1.hidIndex.value != "")
{
setBoard(Form1.hidIndex.value);
}
}
MultiPageTabStrip.hidIndex.Value = n;?
MultiPageTabStrip.hidIndex.Value = n;这句话加在secBoard(n)中的哪个位置?我是这样改的:<script language="javascript">
function secBoard(n)
{ for(i=0;i<secTable.cells.length;i++)
secTable.cells[i].className="sec1";
secTable.cells[n].className="sec2";
for(i=0;i<mainTable.tBodies.length;i++)
mainTable.tBodies[i].style.display="none";
mainTable.tBodies[n].style.display="block";
MultiPageTabStrip.hidIndex.Value = n;
}
function window.onload()
{
if(MultiPageTabStrip.hidIndex.value != "")
{
setBoard(MultiPageTabStrip.hidIndex.value);
}
}
</script>
function secBoard(n)
{
for(i=0;i<secTable.cells.length;i++)
secTable.cells[i].className="sec1";
secTable.cells[n].className="sec2";
for(i=0;i<mainTable.tBodies.length;i++)
mainTable.tBodies[i].style.display="none";
mainTable.tBodies[n].style.display="block";
Form1.hidIndex.Value = n;
}
function window.onload()
{
if(Form1.hidIndex.value != "")
{
setBoard(Form1.hidIndex.value);
}
}
</script>
2.看hidIndex有没有值.
里面加个alert
2.看hidIndex有没有值 看html源码.
直接把这个写在页面的最后面<Script>
if(Form1.hidIndex.value != "")
{
setBoard(Form1.hidIndex.value);
} </Script>
private void Linkbutton7_Click(object sender, System.EventArgs e)
{
hidIndex.Value="1";
}结果还是不行,hidIndex.Value还是没有值
我加了hidIndex.Value="1";这句后,程序也是没有反应,我感觉是setBoard(Form1.hidIndex.value);这句好像没有起作用慕白兄能否再帮着分析一下原因?
我刚解决了一个静态下downlist和lable联动的问题
function secBoard(n)
{
for(i=0;i<secTable.cells.length;i++)
secTable.cells[i].className="sec1";
secTable.cells[n].className="sec2";
for(i=0;i<mainTable.tBodies.length;i++)
mainTable.tBodies[i].style.display="none";
mainTable.tBodies[n].style.display="block";
Form1.hidIndex.Value = 2;
}
function window.onload()
{
setBoard(Form1.hidIndex.value);
alert('不能添加重复的单号!');
}会弹出“不能添加重复的单号”,但是窗体加载的时候依然是第一卡片,刷新也是第一卡片,hidIndex.Value的值已经写死了是2了,window.onload()这个函数又被执行了,可是预期的效果没有出现,这是为什么呢?
function window.onload()
{
setBoard(2);
}
我刚解决了一个静态下downlist和lable联动的问-----------------
linkbutton执行的是对数据库的增加删除操作,怎么能不刷新呢?静态下downlist和lable联动的问题我也在搞,没搞明白,您帮我看一眼,我是这样做的:function onc()
{
document.all["label26"].innerText = Form1.DropDownList1.value;
}然后:
private void Page_Load(object sender, System.EventArgs e)
{
DropDownList1.Attributes.Add("onclick","onc()");但是没有任何反应
建议这样的情况不要使用linkbutton,使用纯客户端,使用js来进行操作。
直接用setBoard(2)试的,还是达不到预期的效果真是服了,所有的javascript代码在我的程序里面没有一个能起作用的,所有的函数都不好用
建议这样的情况不要使用linkbutton,使用纯客户端,使用js来进行操作。---------------------
单单用js能对数据库进行操作吗?也就是能做到在页面不刷新的情况下进行数据的插入操作吗?我沮丧极了,真是无奈啊
<div class="tabs" id="past">
<div class="tabswitcher">
<ul>
<li class="current"><a onclick="JavaScript:tabOff('2003'); tabOff('2004'); tabOn('2005', event);" title="" id="tab2005">2005年</a></li>
<li><a onclick="JavaScript:tabOff('2003'); tabOn('2004', event); tabOff('2005');" title="" id="tab2004">2004年</a></li>
<li><a onclick="JavaScript:tabOn('2003', event); tabOff('2004'); tabOff('2005');" title="" id="tab2003">2003年</a></li>
</ul>
</div>
<div class="tabpages">
<div class="tabpage" id="2005">
</div>
<div class="tabpage" id="2004" style="display:none;">
</div>
<div class="tabpage" id="2003" style="display:none;">
</div>
</div>
</div><!-- tabs -->/****************** css **********************/
/********** 图片我可以邮件发给你 *************/
div.tabs
{
clear:both;
}
div.tabs div.tabpages
{
}
div.tabs div.tabpages div.tabpage
{
position:relative;
float:left;
padding:4px;
border-color:#000;
border-style:solid;
border-width:0 0px 0px 0px;
}div.tabs div.tabswitcher
{
background:#DAE0D2 url("../images/bg_tabs.gif") repeat-x bottom;
float:left;
width:100%;
font-size:9pt;
line-height:normal;
width:100%;
}
div.tabs div.tabswitcher ul
{
float:left;
margin:0;
padding:10px 0 0 15px;
list-style:none;
width:100%;
}
div.tabs div.tabswitcher li
{
float:left;
background:url("../images/left.gif") no-repeat left top;
margin:0;
padding:0 0 0 9px;
}
div.tabs div.tabswitcher a
{
float:left;
display:block;
background:url("../images/right.gif") no-repeat right top;
padding:5px 15px 4px 6px;
font-family:宋体,Geogia,Serif;
font-size:small;
text-decoration:none;
font-weight:bold;
color:#765;
cursor:hand;
}
/* Commented Backslash Hack
hides rule from IE5-Mac \*/
/* End IE5-Mac hack */
div.tabs div.tabswitcher a:hover
{
color:#333;
}
div.tabs div.tabswitcher .current
{
background-image:url("../images/left_on.gif");
border-width:0;
}
div.tabs div.tabswitcher .current a
{
background-image:url("../images/right_on.gif");
color:#333;
padding-bottom:5px;
}
我一般用的是dropdownlistif(!Page.IsStartupScriptRegistered("upAlert"))
{
Page.RegisterStartupScript("upAlert",@"<script language='javascript'>alert('添加成功!')</script>");
}
--------------------------
可以不放在if(!IsPostBack)里
那就不是这个问题了.setBoard有问题.
函数:
function secBoard(n)
{
for(i=0;i<secTable.cells.length;i++)
secTable.cells[i].className="sec1";
secTable.cells[n].className="sec2";
for(i=0;i<mainTable.tBodies.length;i++)
mainTable.tBodies[i].style.display="none";
mainTable.tBodies[n].style.display="block";
Form1.hidIndex.Value = 2;
}在
function window.onload()
{
secBoard(2);
}
中调用secBoard的时候,把secBoard写成了setBoard,呵呵,终于发现了,改过来就好用了但是还有一个很大的问题,就是选中第三选项卡,点BUTTON控件,刷新,虽然能够切换到第三选项卡,但是速度太慢了,奇慢,至少要五六秒钟,在这个时间里,可以很明显的看到先显示第一选项卡,再切换到第三选项卡,效果看起来很差,有什么办法能让它快一点呢?让人感觉不出来呢?
[email protected]