程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> 關於ASP.NET >> asp.net夜話之十:復合控件和母板頁(二)

asp.net夜話之十:復合控件和母板頁(二)

編輯:關於ASP.NET

下面是一個用javascript來實現的選項卡式效果的例子,完全采用輸出HTML代碼的方式。在這個例子中我們通過css和div來控制當前活動選項卡和非活動選項卡的顯示與否及顯示樣式,疑難部分筆者都做了詳盡注釋,讀者朋友完全可以根據自己的實際需要把代碼改造成自己想要的效果。

以下是設計部分代碼:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JavaScriptMenu.aspx.cs" Inherits="JavaScriptMenu" %>
<!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>JavaScript實現的選項卡式效果</title>
<script language="javascript" type="text/javascript">
function Show_Sub(id_num,num,obj)
{
for(var i = 0;i <= 9;i++)
{
if(GetObj("tabb" + id_num + i))
{
GetObj("tabb" + id_num + i).className = 'guide2';
}
if(GetObj("subb" + id_num + i))
{
GetObj("subb" + id_num + i).style.display = 'none';
}
}
if(GetObj("tabb" + id_num + num))
{
GetObj("tabb" + id_num + num).className = 'guide1';
}
if(GetObj("subb" + id_num + num))
{
GetObj("subb" + id_num + num).style.display = 'block';
}
}
function GetObj(objName)
{
if(document.getElementById)
{
return eval('document.getElementById("' + objName + '")');
}
else
{
return eval('document.all.' + objName);
}
}
</script>
<style type="text/css">
.guide1 {
cursor: hand;
color: #003399;
background-color:#3399FF;
font-weight: bold;
text-decoration: none;
border-right: 1px solid #A2C0FE;
height: 25px;
line-height: 25px;
}
.guide2 {
cursor: hand;
border-right: 1px solid #A2C0FE;
line-height: 25px;
}
.24line {line-height: 24px;}
.pad5 {padding:5px;}
.padtop2 {padding-top:2px;}
.padtop5 {padding-top:5px;}
.t {border-top: 1px solid #A2C0FE;}
.b {border-bottom: 1px solid #A2C0FE;}
.l {border-left: 1px solid #A2C0FE;}
.r {border-right: 1px solid #A2C0FE;}
.right{
float:right;
color: #999999;
}
.left{
float:left;
color: #999999;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=GetUserPanel(0) %>
</div>
</form>
</body>
</html>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved