关于网上流行的Div切换的问题? 大家都知道目前比较流行的div切换吧(不知道的可以看一下网易)问个关于这方面的问题,如果后台自定义 标题和显示的内容,就是让这个div切换里面的标题和内容全是数据库绑定出来的,如何做啊,网上大都是静态的。小弟不胜感激。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在那些绑定数据库的控件中,如datalist,repeater中嵌套div,然后绑定数据也可以..如果用asp.net实现的话. datalist应该不行,它会自动生成table 好像只能用 repeater -_-! 用个DIV把控件包裹起来不就可以了嘛! 如果是web应用,最好还是不要用服务器控件。可以用ajax动态load加载到div里 关于tab的资料很多吧,相关源码也很多哦 "不知道的可以看一下网易,.. 网上大都是静态的。"网上的都是动态的(包括网易的)。这些内容都是从数据库里取出来的,换内容的时候不用去做网页。先做一个静态的,然后用变量替换标题和里面的内容就行了; 或者用代码直接生成HTML串。就是想当于自己做邦定程序。如里静态的也不会做的话,就不好办了。 很简单的,用DIV里再放个IFRAME,IFRAME里面放页面,让这个页面超时时间设为0。在Page_Load方法中 第一句写 Response.Expires = 0; 微软和开源社区的AjaxControlToolkit控件包中有个Ajax控件TabContainer,楼主可以到www.asp.net上去下载,里面有怎么使用的源代码 贴一下代码:以前的代码(是静态的)现在用户要求 自定义标题 和 显示内容:<html xmlns="http://www.w3.org/1999/xhtml" ><head> <title>DivTab</title> <style> body {font-size:12px;font-family:宋体} ul.TabBarLevel1{ list-style:none; margin:0; padding:0; height:29px; color:#ecfde6 background-image:url(images/left_bk.gif); } ul.TabBarLevel1 li{ float:left; padding:0; height:29px; margin-right:1px; background-image:url(images/left_bk.gif); } ul.TabBarLevel1 li a{ display:block; line-height:29px; padding:0 20px; color:#333; white-space: nowrap; } ul.TabBarLevel1 li.Selected{ color:#ecfde6; text-decoration:none;} 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-top:1px solid #a9d87b; border-left: 1px solid #a9d87b; border-right: 1px solid #a9d87b; border-bottom: 1px solid #a9d87b; display:none; } </style></head><script language="JavaScript">//Switch Tab Effectfunction 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> <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 class="HackBox" id="dTab1" style="DISPLAY:block">标签一内容</div> <div id="dTab2" class="HackBox">标签二内容</div> <div id="dTab3" class="HackBox">标签三内容</div> <div id="dTab4" class="HackBox">标签四内容</div> </div> </DIV></body></html>以上是我的静态的Div切换,我把红色的部分用repeater 控件进行绑定, <asp:Repeater ID="ListTitle" runat="server"> <ItemTemplate> <li id=""><a href="#" onclick="" ><%# DataBinder.Eval(Container.DataItem, "TitleName")%></a></li> </ItemTemplate> </asp:Repeater>我的<li> 的 Id 怎么写,如果我定义ID ,查看页面源文件发现<li>的ID都一样,另外 <a> 里面的 onclick 如何写? 请问关于GridView中Select一行的问题 谁有地图标记的源码。 界面类似或者相同侵权吗? 急,在线等~~~~~~~~~写SQL查询语句时,表名有关键字怎么办啊 bin文件夹里的dll问题,巨菜! 中文标点转英文标点 提交以后如何自动刷新本页呢 页面加载同时弹出另一页面,如何“避开”3721的弹出广告拦截。 如何能从服务器端的cs文件中,接收到客户端的变量值! 报表导出到excel格式后,没有边框,怎么回事?? 怎么提高自己的编程水平啊? ajaxToolkit:Calendar提示 元素“Calendar”不是已知元素 错误
应该不行,它会自动生成table 好像只能用 repeater
可以用ajax动态load加载到div里
IFRAME里面放页面,让这个页面超时时间设为0。
在Page_Load方法中 第一句写 Response.Expires = 0;
以前的代码(是静态的)现在用户要求 自定义标题 和 显示内容:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>DivTab</title>
<style>
body {font-size:12px;font-family:宋体}
ul.TabBarLevel1{ list-style:none; margin:0; padding:0; height:29px; color:#ecfde6 background-image:url(images/left_bk.gif); }
ul.TabBarLevel1 li{ float:left; padding:0; height:29px; margin-right:1px; background-image:url(images/left_bk.gif); }
ul.TabBarLevel1 li a{ display:block; line-height:29px; padding:0 20px; color:#333; white-space: nowrap; }
ul.TabBarLevel1 li.Selected{ color:#ecfde6; text-decoration:none;}
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-top:1px solid #a9d87b; border-left: 1px solid #a9d87b; border-right: 1px solid #a9d87b; border-bottom: 1px solid #a9d87b; display:none; }
</style>
</head>
<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>
<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 class="HackBox" id="dTab1" style="DISPLAY:block">标签一内容</div>
<div id="dTab2" class="HackBox">标签二内容</div>
<div id="dTab3" class="HackBox">标签三内容</div>
<div id="dTab4" class="HackBox">标签四内容</div>
</div>
</DIV>
</body>
</html>
以上是我的静态的Div切换,我把红色的部分用repeater 控件进行绑定,
<asp:Repeater ID="ListTitle" runat="server">
<ItemTemplate>
<li id=""><a href="#" onclick="" ><%# DataBinder.Eval(Container.DataItem, "TitleName")%></a></li>
</ItemTemplate>
</asp:Repeater>
我的<li> 的 Id 怎么写,如果我定义ID ,查看页面源文件发现<li>的ID都一样,另外 <a> 里面的 onclick 如何写?