- 浏览: 275611 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
iceblue123:
厉害,太感谢楼主了,第二种方法威武!
spring MVC 3.2中@ResponseBody返回乱码的完美解决方案 -
gaozi131:
感谢啊 折腾了一下午搞定
spring MVC 3.2中@ResponseBody返回乱码的完美解决方案 -
yenshen:
找了半天,问题终于解决了,感谢!
spring MVC 3.2中@ResponseBody返回乱码的完美解决方案 -
笑闯天下:
感觉效率不是很高啊 ,如果从数据库中取到的数据 还要去自己拼接 ...
java导出CSV文件 -
ajonjun:
http://viralpatel.net/
解决ckeditor html不显示,ckeditor 自动过滤html
1.//弹出对话框.点击转向指定页面
Response.Write(" <script>window.alert('该会员没有提交申请,请重新提交!')
</script>");
Response.Write(" <script>window.location
='http://www.51aspx.com/bizpulic/upmeb.aspx' </script>");
2.//弹出对话框
Response.Write(" <script language='javascript'>alert('产品添加成功!')
</script >");
3.//删除文件
string filename ="20059595157517.jpg";
pub.util.DeleteFile(HttpContext.Current.Server.MapPath("../file/")
+filename);
4.//绑定下拉列表框datalist
System.Data.DataView dv=conn.Exec_ex("select -1 as code,'请选择经营模式'
as content from dealin union select code,content from dealin");
this.dealincode.DataSource=dv;
this.dealincode.DataTextField="content";
this.dealincode.DataValueField="code";
this.dealincode.DataBind();
this.dealincode.Items.FindByValue(dv[0]["dealincode"].ToString
()).Selected=true;
5.//时间去秒显示
<%# System.DateTime.Parse(DataBinder.Eval
(Container.DataItem,"begtime").ToString()).ToShortDateString()%>
6.//标题带链接
<%# " <a class=\"12c\" target=\"_blank\"
href=\"http://www.51aspx/CV/_"+DataBinder.Eval
(Container.DataItem,"procode")+".html\">"+
DataBinder.Eval(Container.DataItem,"proname")+" </a>"%>
7.//修改转向
<%# " <A href=\"editpushpro.aspx?id="+DataBinder.Eval
(Container.DataItem,"code")+"\">"+"修改
"+" </A>"%>
8.//弹出确定按钮
<%# " <A id=\"btnDelete\" onclick=\"return confirm('你是否
确定删除这条记录吗?');\" href=\"pushproduct.aspx?
dl="+DataBinder.Eval(Container.DataItem,"code")
+"\">"+"删除"+" </A>"%>
9.//输出数据格式化 "{0:F2}" 是格式 F2表示小数点后剩两位
<%# DataBinder.Eval(Container, "DataItem.PriceMoney","{0:F2}
") %>
10.//提取动态网页内容
Uri uri = new Uri("http://www.51aspx.com/");
WebRequest req = WebRequest.Create(uri);
WebResponse resp = req.GetResponse();
Stream str = resp.GetResponseStream();
StreamReader sr = new StreamReader(str,System.Text.Encoding.Default);
string t = sr.ReadToEnd();
this.Response.Write(t.ToString());
11.//获取" . "后面的字符
i.ToString().Trim().Substring(i.ToString().Trim().LastIndexOf(".")
+1).ToLower().Trim()
12. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?
id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)<
/script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
12.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(’确认?’)
");
button.attributes.add("onclick","if(confirm(’are you sure...?
’)){return true;}else{return false;}")
13.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " +
intEmpID.ToString()
14.删除表格记录警告
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
switch(e.Item.ItemType)
{
case ListItemType.Item :
case ListItemType.AlternatingItem :
case ListItemType.EditItem:
TableCell myTableCell;
myTableCell = e.Item.Cells[14];
LinkButton myDeleteButton ;
myDeleteButton = (LinkButton)myTableCell.Controls[0];
myDeleteButton.Attributes.Add("onclick","return confirm(’
您是否确定要删除这条信息’);");
break;
default:
break;
}
}
15.点击表格行链接另一页
private void grdCustomer_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//点击表格打开
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
e.Item.Attributes.Add("onclick","window.open(’
Default.aspx?id=" + e.Item.Cells[0].Text + "’);");
}
双击表格连接到另一页
在itemDataBind事件中
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
string orderItemID =e.item.cells[1].Text;
e.item.Attributes.Add("ondblclick",
"location.href=’../ShippedGrid.aspx?id=" + orderItemID + "’
");
}
双击表格打开新一页
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
string orderItemID =e.item.cells[1].Text;
e.item.Attributes.Add("ondblclick", "open
(’../ShippedGrid.aspx?id=" + orderItemID + "’)");
}
16.表格超连接列传递参数
<asp:HyperLinkColumn Target="_blank" headertext="ID号"
DataTextField="id" NavigateUrl="aaa.aspx?id=’
<%# DataBinder.Eval(Container.DataItem, "数据字段1")%>’ &
name=’<%# DataBinder.Eval(Container.DataItem, "数据字段2")%>’ /
>
17.表格点击改变颜色
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add
("onclick","this.style.backgroundColor=’#99cc00’;
this.style.color=’buttontext’;this.style.cursor=’default’;");
}
写在DataGrid的_ItemDataBound里
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add
("onmouseover","this.style.backgroundColor=’#99cc00’;
this.style.color=’buttontext’;this.style.cursor=’default’;");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=
’’;this.style.color=’’;");
}
18.关于日期格式
日期格式设定
DataFormatString="{0:yyyy-MM-dd}"
我觉得应该在itembound事件中
e.items.cell["你的列"].text=DateTime.Parse(e.items.cell["你的
列"].text.ToString("yyyy-MM-dd"))
19.获取错误信息并到指定页面
不要使用Response.Redirect,而应该使用Server.Transfer
e.g
// in global.asax
protected void Application_Error(Object sender, EventArgs e) {
if (Server.GetLastError() is HttpUnhandledException)
Server.Transfer("MyErrorPage.aspx");
//其余的非HttpUnhandledException异常交给ASP.NET自己处理就okay了
}
Redirect会导致post-back的产生从而丢失了错误信息,所以页面导向应该直接在服
务器端执行,这样就可以在错误处理页面得到出错信息并进行相应的处理
20.清空Cookie
Cookie.Expires=[DateTime];
Response.Cookies("UserName").Expires = 0
Response.Write(" <script>window.alert('该会员没有提交申请,请重新提交!')
</script>");
Response.Write(" <script>window.location
='http://www.51aspx.com/bizpulic/upmeb.aspx' </script>");
2.//弹出对话框
Response.Write(" <script language='javascript'>alert('产品添加成功!')
</script >");
3.//删除文件
string filename ="20059595157517.jpg";
pub.util.DeleteFile(HttpContext.Current.Server.MapPath("../file/")
+filename);
4.//绑定下拉列表框datalist
System.Data.DataView dv=conn.Exec_ex("select -1 as code,'请选择经营模式'
as content from dealin union select code,content from dealin");
this.dealincode.DataSource=dv;
this.dealincode.DataTextField="content";
this.dealincode.DataValueField="code";
this.dealincode.DataBind();
this.dealincode.Items.FindByValue(dv[0]["dealincode"].ToString
()).Selected=true;
5.//时间去秒显示
<%# System.DateTime.Parse(DataBinder.Eval
(Container.DataItem,"begtime").ToString()).ToShortDateString()%>
6.//标题带链接
<%# " <a class=\"12c\" target=\"_blank\"
href=\"http://www.51aspx/CV/_"+DataBinder.Eval
(Container.DataItem,"procode")+".html\">"+
DataBinder.Eval(Container.DataItem,"proname")+" </a>"%>
7.//修改转向
<%# " <A href=\"editpushpro.aspx?id="+DataBinder.Eval
(Container.DataItem,"code")+"\">"+"修改
"+" </A>"%>
8.//弹出确定按钮
<%# " <A id=\"btnDelete\" onclick=\"return confirm('你是否
确定删除这条记录吗?');\" href=\"pushproduct.aspx?
dl="+DataBinder.Eval(Container.DataItem,"code")
+"\">"+"删除"+" </A>"%>
9.//输出数据格式化 "{0:F2}" 是格式 F2表示小数点后剩两位
<%# DataBinder.Eval(Container, "DataItem.PriceMoney","{0:F2}
") %>
10.//提取动态网页内容
Uri uri = new Uri("http://www.51aspx.com/");
WebRequest req = WebRequest.Create(uri);
WebResponse resp = req.GetResponse();
Stream str = resp.GetResponseStream();
StreamReader sr = new StreamReader(str,System.Text.Encoding.Default);
string t = sr.ReadToEnd();
this.Response.Write(t.ToString());
11.//获取" . "后面的字符
i.ToString().Trim().Substring(i.ToString().Trim().LastIndexOf(".")
+1).ToLower().Trim()
12. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?
id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)<
/script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
12.为按钮添加对话框
Button1.Attributes.Add("onclick","return confirm(’确认?’)
");
button.attributes.add("onclick","if(confirm(’are you sure...?
’)){return true;}else{return false;}")
13.删除表格选定记录
int intEmpID = (int)MyDataGrid.DataKeys[e.Item.ItemIndex];
string deleteCmd = "Delete from Employee where emp_id = " +
intEmpID.ToString()
14.删除表格记录警告
private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)
{
switch(e.Item.ItemType)
{
case ListItemType.Item :
case ListItemType.AlternatingItem :
case ListItemType.EditItem:
TableCell myTableCell;
myTableCell = e.Item.Cells[14];
LinkButton myDeleteButton ;
myDeleteButton = (LinkButton)myTableCell.Controls[0];
myDeleteButton.Attributes.Add("onclick","return confirm(’
您是否确定要删除这条信息’);");
break;
default:
break;
}
}
15.点击表格行链接另一页
private void grdCustomer_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//点击表格打开
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
e.Item.Attributes.Add("onclick","window.open(’
Default.aspx?id=" + e.Item.Cells[0].Text + "’);");
}
双击表格连接到另一页
在itemDataBind事件中
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
string orderItemID =e.item.cells[1].Text;
e.item.Attributes.Add("ondblclick",
"location.href=’../ShippedGrid.aspx?id=" + orderItemID + "’
");
}
双击表格打开新一页
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
string orderItemID =e.item.cells[1].Text;
e.item.Attributes.Add("ondblclick", "open
(’../ShippedGrid.aspx?id=" + orderItemID + "’)");
}
16.表格超连接列传递参数
<asp:HyperLinkColumn Target="_blank" headertext="ID号"
DataTextField="id" NavigateUrl="aaa.aspx?id=’
<%# DataBinder.Eval(Container.DataItem, "数据字段1")%>’ &
name=’<%# DataBinder.Eval(Container.DataItem, "数据字段2")%>’ /
>
17.表格点击改变颜色
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add
("onclick","this.style.backgroundColor=’#99cc00’;
this.style.color=’buttontext’;this.style.cursor=’default’;");
}
写在DataGrid的_ItemDataBound里
if (e.Item.ItemType == ListItemType.Item ||e.Item.ItemType ==
ListItemType.AlternatingItem)
{
e.Item.Attributes.Add
("onmouseover","this.style.backgroundColor=’#99cc00’;
this.style.color=’buttontext’;this.style.cursor=’default’;");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=
’’;this.style.color=’’;");
}
18.关于日期格式
日期格式设定
DataFormatString="{0:yyyy-MM-dd}"
我觉得应该在itembound事件中
e.items.cell["你的列"].text=DateTime.Parse(e.items.cell["你的
列"].text.ToString("yyyy-MM-dd"))
19.获取错误信息并到指定页面
不要使用Response.Redirect,而应该使用Server.Transfer
e.g
// in global.asax
protected void Application_Error(Object sender, EventArgs e) {
if (Server.GetLastError() is HttpUnhandledException)
Server.Transfer("MyErrorPage.aspx");
//其余的非HttpUnhandledException异常交给ASP.NET自己处理就okay了
}
Redirect会导致post-back的产生从而丢失了错误信息,所以页面导向应该直接在服
务器端执行,这样就可以在错误处理页面得到出错信息并进行相应的处理
20.清空Cookie
Cookie.Expires=[DateTime];
Response.Cookies("UserName").Expires = 0
发表评论
-
C#/.NET主线程与子线程之间的关系
2009-12-22 23:10 2343以前一直没有在程序中写过总结,再翻开程序时却不知所云,所以我决 ... -
Using sqlite with .NET
2009-12-08 00:01 887The other day I found that ther ... -
C#操作Excel,套用模板并对数据进行分页
2009-12-07 23:52 2117using System; using System.I ... -
动态生成缩略图
2009-12-07 23:49 1308Util.cs 的部分代码: //// <summa ... -
如何获取客户IE统计信息
2009-12-07 23:47 996namespace Huawei.com { p ... -
运用API函数获取系统信息
2009-12-07 23:44 1078<HTML> <HEAD> ... -
WMI类-所有可用的WMI的类封装
2009-12-07 23:43 1655public class WMIClasses ... -
自己写的一个文件上传的类
2009-12-07 23:42 1034using System; using System.C ... -
文件操作工具类 FileUtility
2009-12-07 23:41 1228最近一直在研究 Smart Client 的 Smart Up ... -
C# 检查字符串,防SQL注入攻击
2009-12-07 23:16 1780例子里暂定为=号和'号 bool CheckParams ... -
获取本机机器名和登录WINDOWS的用户名?
2009-12-07 23:13 3605using System; using System. ... -
C# 禁用ctrl+alt+del
2009-12-07 23:09 1776using System; using System.R ... -
获取应用程序进程实例,
2009-12-07 23:07 1265/// <summary> ... -
如何在C#中使用全局鼠标、键盘Hook
2009-12-07 23:03 2604今天,有个同事问我,怎样在C#中使用全局钩子?以前写的全局钩子 ... -
把Web Control导出为Excel或Word
2009-12-07 22:58 1007/// <summary> /// 将Web ... -
C#编程忘记密码功能的实现方法
2009-12-07 22:55 2350以下是引用片段: int result = user.Ge ... -
C#实现USB接口的程序代码
2009-12-07 22:53 1841namespace ConsoleApplication1 ... -
Textarea标签封装为Web在线编辑器
2009-12-07 22:42 1053Editor.htm <textarea style ... -
定自已的格式化类
2009-12-07 22:20 787public class Vector:IFormatta ... -
调用winapi中的FlashWindow
2009-12-07 22:18 13971.引用 using System.Runtime.In ...
相关推荐
ASP.NET常用语句1--20条,(很实用的) ASP.NET常用语句1--20条,(很实用的)
ASP.NET常用语句1--26条,实用。最好的常用语句笔记。开发所需的必备资源。
第4章 ASP.NET内置对象和页面配置,介绍了ASP.NET的页面常用修饰符、常用内置对象的使用方法,以及ASP.NET的运行配置文件。 第5章 .NET框架类,介绍了常用框架类的命名控件System.IO、System.Web、...
虽然说学习ASP.NET不需要任何ASP基础,但是我觉得如果大家ASP不会,还是先看一下【十天学会ASP教程】,大家所需要了解的不是ASP的程序怎么写,而是怎么构建服务器,怎么使用HTML表单,同时对SQL语句有一个基础和理解...
ASP.NET 2.0使用Web Part创建应用程序之二(共二) 体验 .net2.0 的优雅(2) -- ASP.net 主题和皮肤 NET2.0系列介绍(一).NET 2.0 中Web 应用程序主题的切换 ASP.NET 2.0 中Web 应用程序主题的切换 2.0正式版中...
一般常用小代码语句 像 重载此警告窗口,使某控件获得焦点 很实用 初期都是需要注意的小功能
1.6.1 如何创建ASP.NET项目 58 1.6.2 如何创建Windows项目 61 1.6.3 Visual Studio.NET 2008 操作与使用技巧 61 1.6.4 常见开发调试技巧 66 1.6.5 错误异常处理方法 70 本章常见技术面试题 76 常见面试技巧之面试...
1.6.1 如何创建ASP.NET项目 58 1.6.2 如何创建Windows项目 61 1.6.3 Visual Studio.NET 2008 操作与使用技巧 61 1.6.4 常见开发调试技巧 66 1.6.5 错误异常处理方法 70 本章常见技术面试题 76 常见面试技巧之面试...
非常经典的高校C# .net开发教程,《Visual C#.NET程序设计》作者,李兰友,杨晓光,清华出版社,北交出版社,含有书籍和源码。 本书主要介绍Visual C#.NET应用程序设计技术。内容包括:Visual C#.NET集成环境,常用...
/*============================================================================== ... * 学习和讨论有关asp.net mvc ,Ajax ,jquery ,,html/css,xml ,sqlserver ,wpf,IIS相关技术的交流和学习。
基本信息 书名:高等学校计算机应用规划教材:Visual C# 2010程序设计教程 作者: 陈建伟 出版社: 清华大学出版社 页码:326 ...第12章 Web应用程序开发及ASP.NET 第13章 文件处理 第14章 语言集成查询-LINQ
供Asp.Net直接调用的包装类(WebPreview.cs) 计算机重启、关电源、注销、关闭显示器辅助类(WindowsExitHelper.cs) ----------NONONONO-------------- 全局统一的缓存类(Cache.cs) 常用显示日期时间、农历、生肖的...
常用类方法 GeneralHelper.cs 开发常用方法,由于多个存在,项目开发新建单独调用 ?Web Class Name File Function 网页界面功能类 WebUI.cs 控件,文本的界面处理功能 UBB代码辅助类 UBB.cs UBB代码转换 客户端代码功能...
8.6. mysqlbinlog:用于处理二进制日志文件的实用工具 8.7. mysqlcheck:表维护和维修程序 8.8. mysqldump:数据库备份程序 8.9. mysqlhotcopy:数据库备份程序 8.10. mysqlimport:数据导入程序 8.11. mysqlshow-...
8.6. mysqlbinlog:用于处理二进制日志文件的实用工具 8.7. mysqlcheck:表维护和维修程序 8.8. mysqldump:数据库备份程序 8.9. mysqlhotcopy:数据库备份程序 8.10. mysqlimport:数据导入程序 8.11. mysqlshow-...
8.6. mysqlbinlog:用于处理二进制日志文件的实用工具 8.7. mysqlcheck:表维护和维修程序 8.8. mysqldump:数据库备份程序 8.9. mysqlhotcopy:数据库备份程序 8.10. mysqlimport:数据导入程序 8.11. mysqlshow-...
8.6. mysqlbinlog:用于处理二进制日志文件的实用工具 8.7. mysqlcheck:表维护和维修程序 8.8. mysqldump:数据库备份程序 8.9. mysqlhotcopy:数据库备份程序 8.10. mysqlimport:数据导入程序 8.11. mysqlshow-...
8.6. mysqlbinlog:用于处理二进制日志文件的实用工具 8.7. mysqlcheck:表维护和维修程序 8.8. mysqldump:数据库备份程序 8.9. mysqlhotcopy:数据库备份程序 8.10. mysqlimport:数据导入程序 8.11. ...