<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js的onload方法的使用</title>
<script type="text/javascript">
window.onload=function(){
var myLinks = document.getElementsByTagName("a");
for(var i=0 ; i<myLinks.length; i++){
myLinks[i].onclick=function(){
alert("链接了");
}
}
}
</script>
</head>
<body>
<h1>js的onload方法的使用</h1>
<a href=/blog_article/"/index.html > <a href=/blog_article/"/index.html > <a href=/blog_article/"/index.html > <a href=/blog_article/"/index.html > <a href=/blog_article/"/index.html > <a href=/blog_article/"/index.html > </body>
</html>
jquery的ready方法的实现:
一个问题是有关于用js去替换htm指定标签之间的内容
var str = "bbb<b>方法反反复复</b>";
var aa=reg.exec(str)
var str1=RegExp.$1;
var bb=str.replace(str1,"s")
alert(bb)
以上代码执行之后的结果是:bbbs
本文链接
SelectNewsClass.aspx(查询新闻分类)前台
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>类别名称:</td>
<td> <asp:TextBox ID="txtClassName" runat="server"></asp:TextBox></td>
<td> <asp:Button ID="btnSelectClass" runat="server" Text="查看"
onclick="btnSelectClass_Click" /></td>
<td> <asp:Button ID="btnAssClass" runat="server" Text="添加"
onclick="btnAssClass_Click" /></td>
</tr>
</table>
<div id="divResult" runat="server"></div>
</div>
</form>
</body>
SelectNewsClass.aspx.cs(查询新闻分类)后台
string conStr = @"Data Source=.;Initial Catalog=News;Persist Security Info=True;User ID=sa;Password=111111";
string ispostback = string.Empty;
string a = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
ispostback = Request.QueryString["ispostback"];
a = Request.QueryString["a"];
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["key"]))
{
txtClassName.Text = Request.QueryString["key"];
ClassLoad();
}
if (ispostback == "1")
{
ClassLoad();
}
if (a == "3")
{
ClassLoad();
}
}
}
protected void btnSelectClass_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtClassName.Text))
{
txtClassName.Text = "请输入您要查询的数据";
return;
}
ClassLoad();
}
private void ClassLoad()
{
SqlConnection conn = new SqlConnection(conStr);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
if (ispostback == "1")
{
cmd.CommandText = "select T1.Id,T1.ClassName,T2.RealName,T1.CreateTime from T_NewsClass T1 inner join T_User T2 on T1.ClassCreator=T2.UserId Order by T1.Id DESC ";
}
else
{
cmd.CommandText = "select T1.Id,T1.ClassName,T2.RealName,T1.CreateTime from T_NewsClass T1 inner join T_User T2 on T1.ClassCreator=T2.UserId where ClassName like
'%'+@classname+'%' Order by T1.Id DESC ";
cmd.Parameters.AddWithValue("@classname", txtClassName.Text);
}
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
StringBuilder sb1 = new StringBuilder();
sb1.Append("<table bgcolor='#3399ff'>");
foreach (DataRow row in dt.Rows)
{
sb1.Append("<tr>");
sb1.Append("<td>" + row["ClassName"].ToString() + "</td>");
sb1.Append("<td>" + row["RealName"].ToString() + "</td>");
sb1.Append("<td>" + row["CreateTime"].ToString() + "</td>");
sb1.Append("<td><a href='/blog_article/EditNewsClass/id/quot; /.html'>编辑</a></td>");
sb1.Append("</tr>");
}
sb1.Append("</table>");
divResult.InnerHtml = sb1.ToString();
cmd.Dispose();
conn.Dispose();
}
protected void btnAssClass_Click(object sender, EventArgs e)
{
Response.Redirect("AddNewsClass.aspx");
}
EditNewsClass.aspx(修改新闻分类)前台
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td>类别名称:</td><td>
<asp:TextBox ID="txtClassName" runat="server"></asp:TextBox></td></tr>
<tr><td>创建人:</td><td>
&nb