仿博客项目整理笔记
2012-11-26 14:58
281 查看
js
动态创建div并绑定事件
var div = document.createElement("div");//创建div存放页数
div.className = "tooltip";
div.innerHTML =i;
div.name = "t"+i+"";
div.style.position = "absolute";
div.style.borderstyle = "solid";
div.style.border = "red";
div.style.left = ""+la+"px";
div.style.width = 100;
div.onclick = function xxx() {//将div与事件绑定动态
for (var i = 1; i <= x; i++) {//将table全部隐藏
var q1 = document.getElementById("t" + i + "");
q1.style.display = "none";
}
oooo = this.name//得到具体哪个按钮激发的事件
var q = document.getElementById(oooo);
q.style.display = "block";
};
var son_td = document.createElement("TD");
son_td.appendChild(div);//将div存放至表格TD中
son_tr.appendChild(son_td);
<link type="text/css" rel="Stylesheet" href="css/xwz.css"/>//连接至css
<script type="text/javascript" src="xjs.js"></script>//连接至js
web后台
Table qqq = new Table();//动态创建table
TableRow Row = new TableRow();//新建行
Row.CssClass = "tbiaoge";//为新建行提供classname方便css调整位置
TableRow Row1 = new TableRow();//新建列
Row1.CssClass = "tbiaoge1";
TableCell Cell1 = new TableCell();
string xxxxx = reader.GetString(reader.GetOrdinal("tfl"));//得到数据库中字段为tfl的值
Cell1.Text = xxxxx;
Row1.Cells.Add(Cell1);//没次创建两行,第二行为回复信息只需一列。将每列添加到行中
qqq.Rows.Add(Row);
qqq.Rows.Add(Row1);//将每行添加进table中
xplgl.Controls.Add(qqq);//将动态创建的表格添加到网页指定的空间
Button xb = new Button();
xb.Text = "删除";
xb.CommandName = id.ToString();
xb.BorderStyle = BorderStyle.None;
xb.ForeColor = System.Drawing.Color.Red;//为动态添加的按钮字体颜色赋值
xb.Click += new EventHandler(xsc);//动态为按钮添加事件
public void xsc(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connStr))
{conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
Button b1 = (Button)sender;//得到具体是哪个按钮触法的时间通过按钮的属性判断连接的时间视哪个
int x = Convert.ToInt32(b1.CommandName);
cmd.CommandText = "delete from xfl where id="+x+"";
cmd.ExecuteNonQuery();
Response.Redirect("xpl.aspx");//跳转页面
}
}
}
网页间的传值
传值
Response.Redirect("gerenxiangxi.aspx?id1="啊啊啊啊啊啊"");
接收
string ooo=Request["id1"];
配置文件中添加数据库连接的方法
添加连接
<connectionStrings>
<add name="sqlcon1" connectionString="data source=XWZ\实例2008;initial catalog=yhgl;user id=sa;password=123" />
</connectionStrings>
调用
string constr =ConfigurationManager.ConnectionStrings["sqlcon1"].ConnectionString;
动态创建div并绑定事件
var div = document.createElement("div");//创建div存放页数
div.className = "tooltip";
div.innerHTML =i;
div.name = "t"+i+"";
div.style.position = "absolute";
div.style.borderstyle = "solid";
div.style.border = "red";
div.style.left = ""+la+"px";
div.style.width = 100;
div.onclick = function xxx() {//将div与事件绑定动态
for (var i = 1; i <= x; i++) {//将table全部隐藏
var q1 = document.getElementById("t" + i + "");
q1.style.display = "none";
}
oooo = this.name//得到具体哪个按钮激发的事件
var q = document.getElementById(oooo);
q.style.display = "block";
};
var son_td = document.createElement("TD");
son_td.appendChild(div);//将div存放至表格TD中
son_tr.appendChild(son_td);
<link type="text/css" rel="Stylesheet" href="css/xwz.css"/>//连接至css
<script type="text/javascript" src="xjs.js"></script>//连接至js
web后台
Table qqq = new Table();//动态创建table
TableRow Row = new TableRow();//新建行
Row.CssClass = "tbiaoge";//为新建行提供classname方便css调整位置
TableRow Row1 = new TableRow();//新建列
Row1.CssClass = "tbiaoge1";
TableCell Cell1 = new TableCell();
string xxxxx = reader.GetString(reader.GetOrdinal("tfl"));//得到数据库中字段为tfl的值
Cell1.Text = xxxxx;
Row1.Cells.Add(Cell1);//没次创建两行,第二行为回复信息只需一列。将每列添加到行中
qqq.Rows.Add(Row);
qqq.Rows.Add(Row1);//将每行添加进table中
xplgl.Controls.Add(qqq);//将动态创建的表格添加到网页指定的空间
Button xb = new Button();
xb.Text = "删除";
xb.CommandName = id.ToString();
xb.BorderStyle = BorderStyle.None;
xb.ForeColor = System.Drawing.Color.Red;//为动态添加的按钮字体颜色赋值
xb.Click += new EventHandler(xsc);//动态为按钮添加事件
public void xsc(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(connStr))
{conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
Button b1 = (Button)sender;//得到具体是哪个按钮触法的时间通过按钮的属性判断连接的时间视哪个
int x = Convert.ToInt32(b1.CommandName);
cmd.CommandText = "delete from xfl where id="+x+"";
cmd.ExecuteNonQuery();
Response.Redirect("xpl.aspx");//跳转页面
}
}
}
网页间的传值
传值
Response.Redirect("gerenxiangxi.aspx?id1="啊啊啊啊啊啊"");
接收
string ooo=Request["id1"];
配置文件中添加数据库连接的方法
添加连接
<connectionStrings>
<add name="sqlcon1" connectionString="data source=XWZ\实例2008;initial catalog=yhgl;user id=sa;password=123" />
</connectionStrings>
调用
string constr =ConfigurationManager.ConnectionStrings["sqlcon1"].ConnectionString;
相关文章推荐
- 近期项目笔记整理
- Cocos2dx 学习笔记整理----在项目中使用图片(二)
- 图像搜索项目整理笔记
- 学习笔记之maven2学习总结(3,maven2在淘宝项目的应用) [ 光影人像 东海陈光剑 的博客 ]
- Cocos2dx 学习笔记整理----第一个项目
- 旅游项目笔记(一)问题整理
- 文顶顶iOS开发博客链接整理及部分项目源代码下载
- 项目经验之:MVVM初学者图形化笔记整理。。。
- Cocos2dx 学习笔记整理----在项目中使用图片(三)
- 近期项目笔记整理(二)
- 个人博客项目笔记
- 文顶顶iOS开发博客链接整理及部分项目源代码下载
- Xcode执行项目整理——main方法简单笔记
- Cocos2dx 学习笔记整理----在项目中使用图片(一)
- 程序员做业余项目、记笔记和写博客的重要性【经典】
- Android热门博客社区开源项目整理
- 1 学习笔记 借鉴别人的博客,整理过来,切实解决了问题。只有链接哈哈。
- v512工作室_刘伟_Java高端培训系列视频_2009年博客系统项目笔记心得
- 【博客项目笔记】ckeditor不能正常显示的问题