ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:23.71KB ,
资源ID:16517830      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/16517830.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(ASPNET中常用的33种代码Word下载.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

ASPNET中常用的33种代码Word下载.docx

1、4.删除表格记录警告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.Cells14;LinkButton myDeleteButton ;myDeleteButton = (LinkButton)my

2、TableCell.Controls0;myDeleteButton.Attributes.Add(return confirm(您是否确定要删除这条信息);break;default:5.点击表格行链接另一页private void grdCustomer_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)/点击表格打开if (e.Item.ItemType = ListItemType.Item | e.Item.ItemType = ListItemType.Alternating

3、Item)e.Item.Attributes.Add(window.open(Default.aspx? + e.Item.Cells0.Text + );双击表格连接到另一页在itemDataBind事件中if(e.Item.ItemType = ListItemType.Item | e.Item.ItemType = ListItemType.AlternatingItem)string OrderItemID =e.item.cells1.Text;.e.item.Attributes.Add(ondblclick, location.href=./ShippedGrid.aspx?

4、+ OrderItemID + 双击表格打开新一页open(./ShippedGrid.aspx?6.表格超连接列传递参数asp:HyperLinkColumn Target=_blank headertext=ID号 DataTextField= NavigateUrl=aaa.aspx?id=%# DataBinder.Eval(Container.DataItem, 数据字段1)% & name=%# DataBinder.Eval(Container.DataItem, 数据字段2)% /7.表格点击改变颜色if (e.Item.ItemType = ListItemType.Item

5、 |e.Item.ItemType = ListItemType.AlternatingItem)e.Item.Attributes.Add(this.style.backgroundColor=#99cc00; this.style.color=buttontext;this.style.cursor=default;写在DataGrid的_ItemDataBound里e.Item.Attributes.Add(onmouseoverthis.style.color=buttontext;onmouseoutthis.style.backgroundColor=;this.style.col

6、or=;8.关于日期格式日期格式设定DataFormatString=0:yyyy-MM-dd我觉得应该在itembound事件中e.items.cell你的列.text=DateTime.Parse(e.items.cell.text.ToString(yyyy-MM-dd)9.获取错误信息并到指定页面不要使用Response.Redirect,而应该使用Server.Transfere.g/ in global.asaxprotected void Application_Error(Object sender, EventArgs e) if (Server.GetLastError()

7、 is HttpUnhandledException)Server.Transfer(MyErrorPage.aspx/其余的非HttpUnhandledException异常交给ASP.NET自己处理就okay了 :Redirect会导致postback的产生从而丢失了错误信息,所以页面导向应该直接在服务器端执行,这样就可以在错误处理页面得到出错信息并进行相应的处理10.清空CookieCookie.Expires=DateTime;Response.Cookies(UserName).Expires = 011.自定义异常处理/自定义异常处理类using System;using Syst

8、em.Diagnostics;namespace MyAppException/ summary/ 从系统异常类ApplicationException继承的应用程序异常处理类。/ 自动将异常内容记录到Windows NT/2000的应用程序日志/ /summarypublic class AppException:System.ApplicationExceptionpublic AppException()if (ApplicationConfiguration.EventLogEnabled)LogEvent(出现一个未知错误。public AppException(string mes

9、sage)LogEvent(message);public AppException(string message,Exception innerException)if (innerException != null)LogEvent(innerException.Message);/日志记录类using System;using System.Configuration;using System.Diagnostics;using System.IO;using System.Text;using System.Threading;namespace MyEventLog/ summary

10、/ 事件日志记录类,提供事件日志记录支持/ remarks/ 定义了4个日志记录方法 (error, warning, info, trace)/ /remarks/ /summarypublic class ApplicationLog/ summary/ 将错误信息记录到Win2000/NT事件日志中/ param name=message需要记录的文本信息/param/ /summarypublic static void WriteError(String message)WriteLog(TraceLevel.Error, message);/ 将警告信息记录到Win2000/NT事

11、件日志中public static void WriteWarning(String message)WriteLog(TraceLevel.Warning, message);/ 将提示信息记录到Win2000/NT事件日志中public static void WriteInfo(String message)WriteLog(TraceLevel.Info, message);/ 将跟踪信息记录到Win2000/NT事件日志中public static void WriteTrace(String message)WriteLog(TraceLevel.Verbose, message)

12、;/ 格式化记录到事件日志的文本信息格式ex需要格式化的异常对象/paramcatchInfo异常信息标题字符串./param/ retvalue/ para格式后的异常信息字符串,包括异常内容和跟踪堆栈./para/ /retvaluepublic static String FormatException(Exception ex, String catchInfo)StringBuilder strBuilder = new StringBuilder();if (catchInfo != String.Empty)strBuilder.Append(catchInfo).Append(

13、rnstrBuilder.Append(ex.Message).Append().Append(ex.StackTrace);return strBuilder.ToString();/ 实际事件日志写入方法level要记录信息的级别(error,warning,info,trace)./parammessageText要记录的文本./paramprivate static void WriteLog(TraceLevel level, String messageText)tryEventLogEntryType LogEntryType;switch (level)case TraceLe

14、vel.Error:LogEntryType = EventLogEntryType.Error;break;case TraceLevel.Warning:LogEntryType = EventLogEntryType.Warning;case TraceLevel.Info:LogEntryType = EventLogEntryType.Information;case TraceLevel.Verbose:LogEntryType = EventLogEntryType.SuccessAudit;default:EventLog eventLog = new EventLog(App

15、lication, ApplicationConfiguration.EventLogMachineName, ApplicationConfiguration.EventLogSourceName );/写入事件日志eventLog.WriteEntry(messageText, LogEntryType);catch /忽略任何异常 /class ApplicationLog12.Panel 横向滚动,纵向自动扩展panel style=overflow-x:scroll;overflow-y:auto;/asp:panel13.回车转换成Tabscript language=javasc

16、ript for=document event=onkeydownif(event.keyCode=13 & event.srcElement.type!=button &=submit & event.srcElement.type!=reset &=&=textarea);event.keyCode=9;/scriptonkeydown=if(event.keyCode=13) event.keyCode=914.DataGrid超级连接列DataNavigateUrlField=字段名 DataNavigateUrlFormatString=http:/xx/inc/delete.asp

17、x?ID=015.DataGrid行随鼠标变色private void DGzf_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)if (e.Item.ItemType!=ListItemType.Header)e.Item.Attributes.Add( this.style.backgroundColor=+e.Item.StyleBACKGROUND-COLOR+ #EFF3F7+16.模板列ASP:TEMPLATECOLUMN visible=False sortexpress

18、ion=demoIDITEMTEMPLATELABEL text=%# DataBinder.Eval(Container.DataItem, ArticleID)% runat=server width=80% id=lblColumn /ITEMTEMPLATE/ASP:TEMPLATECOLUMNTEMPLATECOLUMN headertext=选中HEADERSTYLE wrap= horizontalalign=Center/HEADERSTYLECHECKBOX id=chkExport runat=EDITITEMTEMPLATEchkExportON enabled=true

19、/EDITITEMTEMPLATE后台代码protected void CheckAll_CheckedChanged(object sender, System.EventArgs e)/改变列的选定,实现全选或全不选。CheckBox chkExport ;if( CheckAll.Checked)foreach(DataGridItem oDataGridItem in MyDataGrid.Items)chkExport = (CheckBox)oDataGridItem.FindControl(chkExport.Checked = true;elsechkExport.Checke

20、d = false;17.数字格式化【%#Container.DataItem(price)%的结果是500.0000,怎样格式化为500.00?】%#Container.DataItem(¥#,#0.00)%int i=123456;string s=i.ToString(#,#.0018.日期格式化【aspx页面内:%# DataBinder.Eval(Container.DataItem,Company_Ureg_Date显示为: 2004-8-11 19:44:28我只想要:2004-8-11 】yyyy-M-d应该如何改?【格式化日期】取出来,一般是object(DateTime)objectFromDB).ToString(【日期的验证表达式】A.以下正确的输入格式: 2004-2-29, 2004-02-29 10:29:39 pm, 2004/12/31(d2(02468048)|(1357926)-/s?(0?13578)|(102)-/s?(0?1-9)|(1-20-9)|(301)|(0?469)|(11)-/s?1-9)|(1-20-9)|(30)|(0?2-/s?1-9)|(1-20-9)|(d2(024681235679)|(1357901345789)-/s?(

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1