复制代码 代码如下:
default.aspx
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" validateRequest="false" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<style type="text/css">
*{
font-size:12px;
}
#menu{
padding:0;
margin:0;
}
#menu li{
list-style-type:none;
float:left;
margin-right:10px;
}
.myTable,.myTable td{
border:1px solid #cccccc;
border-collapse:collapse;
}
</style>
<script language="javascript" type="text/javascript">
//js代码部分来自“天下无双”网友
function AddText(NewCode){
setfocus();
var edit = document.selection.createRange();
if(edit){
if(edit.text.length > 0){
edit.text += NewCode;
}else{
edit.text = NewCode;
}
edit.select();
}
}
function setfocus(){
getinput().focus();
}
function getinput(){
return document.getElementById("tbxContent");
}
function code(){
addText = "\r[ code]\r
";
AddText(addText);
}
function html(){
addText = "\r
点击运行可以看到效果:
[Ctrl+A 全选 提示:你可先修改部分代码,再按运行]
";
AddText(addText);
}
function page(){
addText = "[ page]";
AddText(addText);
}
function runCode(cod1){cod=document.getElementById(cod1);var codcode=cod.value;if(code!=""){var newwin=window.open('','','');newwin.opener=null;newwin.document.write(code);newwin.document.close();}}
function copyCode(obj){var temp=document.getElementById(obj);if(document.all){var rng=document.body.createTextRange();rng.moveToElementText(temp);rng.scrollIntoView();rng.select();rng.execCommand("Copy");rng.collapse(false);}else
{window.alert("此功能仅在IE上有效");}}
function saveCode(obj){var winname=window.open('','_blank','top=10000');winname.document.open('text/html','replace');winname.document.write(obj.value);winname.document.execCommand('saveas','','code.htm');winname.close();}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table class="myTable">
<tr>
<td>标题:</td>
<td style="width: 478px"><asp:TextBox ID="tbxTitle" runat="server" Width="277px"></asp:TextBox></td>
</tr>
<tr>
<td style="height: 347px">内容:</td>
<td style="width: 478px; height: 347px">
<ul id="menu">
<li><a href="javascript:page()">[插入分页]</a></li>
<li><a href="javascript:code()">[插入代码]</a></li>
<li><a href="javascript:html()">[插入可运行代码]</a></li>
</ul>
<asp:TextBox ID="tbxContent" runat="server" Height="296px" TextMode="MultiLine" Width="469px"></asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnOk" runat="server" Text="生成静态页并分页" OnClick="btnOk_Click" />
</td>
</tr>
</table>
</div>
<asp:Label ID="lbl" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
[/code]
news.htm 复制代码 代码如下:
<!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>
<title>$title$</title>
<script language="javascript" type="text/javascript">
function runCode(cod1){cod=document.getElementById(cod1);var codcode=cod.value;if(code!=""){var newwin=window.open('','','');newwin.opener=null;newwin.document.write(code);newwin.document.close();}}
function copycode(obj){var temp=document.getElementById(obj);if(document.all){var rng=document.body.createTextRange();rng.moveToElementText(temp);rng.scrollIntoView();rng.select();rng.execCommand("Copy");rng.collapse(false);}else
{window.alert("此功能仅在IE上有效");}}
//高亮当前页
window.onload = function(){
var pagelist = document.getElementById("pagelist").getElementsByTagName("a");
for(var i = 0;i < pagelist.length;i++){
var links = pagelist[i].getAttribute("href");
var myURL = document.location.href;
if(myURL.indexOf(links) != -1){
pagelist[i].className = "D";
}
}
}
</script>
<style type="text/css">
body{
text-align:center;
}
h1{
width:100%;
text-align:center;
}
#board{
width:500px;
text-align:left;
}
a{
font-size:12px;
}
a.D:link,a.D:visited{
color:red;
}
</style>
</head>
<body>
<div id="board">
<h1>$title$</h1>
$content$
<div id="pagelist">$pagelist$</div>
</div>
<br />
</body>
</html>
打包下载
/upload/tech/20091011/20091011143903_58e4d44e550d0f7ee0a23d6b02d9b0db.rar