欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    技巧方法.docx

    • 资源ID:18038599       资源大小:46.42KB        全文页数:48页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    技巧方法.docx

    1、技巧方法DataGrid显示指定字符数(2007-04-26 16:57:51) 转载 A DataGrid显示指定字符数日期:2006-08-20 来源: 作者: 字体:大 中小方法一public string strshow(string str1) if (str1.Length30) str1=str1.Substring(0,30); str1+=.; else str1=str1; return str1; ASP.NET程序中常用的三十三种代码_1(2007-04-26 16:53:14) 转载标签: 常用三十三种代码分类: & 1. 打开新的窗口并传送参数: 传送参数:resp

    2、onse.write(scriptwindow.open(*.aspx?id=+this.DropDownList1.SelectIndex+&id1=+.+)/script)接收参数:string a = Request.QueryString(id);string b = Request.QueryString(id1);-2.为按钮添加对话框Button1.Attributes.Add(onclick,return confirm(确认?);button.attributes.add(onclick,if(confirm(are you sure.?)return true;elsere

    3、turn false;)-3.删除表格选定记录int intEmpID = (int)MyDataGrid.DataKeyse.Item.ItemIndex;string deleteCmd = DELETE from Employee where emp_id = + intEmpID.ToString()-4.删除表格记录警告private void DataGrid_ItemCreated(Object sender,DataGridItemEventArgs e)switch(e.Item.ItemType)case ListItemType.Item :case ListItemTy

    4、pe.AlternatingItem :case ListItemType.EditItem:TableCell myTableCell;myTableCell = e.Item.Cells14;LinkButton myDeleteButton ;myDeleteButton = (LinkButton)myTableCell.Controls0;myDeleteButton.Attributes.Add(onclick,return confirm(您是否确定要删除这条信息););break;default:break;-5.点击表格行链接另一页private void grdCustom

    5、er_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.Cells0.Text + ););双击表格连接到另一页在itemDataBind事件中if(e.Item.

    6、ItemType = ListItemType.Item | e.Item.ItemType = ListItemType.AlternatingItem)string OrderItemID =e.item.cells1.Text;.e.item.Attributes.Add(ondblclick, location.href=./ShippedGrid.aspx?id= + OrderItemID + );双击表格打开新一页if(e.Item.ItemType = ListItemType.Item | e.Item.ItemType = ListItemType.AlternatingI

    7、tem)string OrderItemID =e.item.cells1.Text;.e.item.Attributes.Add(ondblclick, open(./ShippedGrid.aspx?id= + OrderItemID + );-6.表格超连接列传递参数asp:HyperLinkColumn Target=_blank headertext=ID号 DataTextField=id NavigateUrl=aaa.aspx?id=%# DataBinder.eval_r(Container.DataItem, 数据字段1)% & name=%# DataBinder.eva

    8、l_r(Container.DataItem, 数据字段2)% /-7.表格点击改变颜色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

    9、= 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=;);-8.关于日期格式日期格式设定DataFormatS

    10、tring=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() is HttpUnhandledExceptio

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

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

    13、age);public AppException(string message,Exception innerException)LogEvent(message);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

    14、/ 事件日志记录类,提供事件日志记录支持/ 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);/ summary/ 将警告信息记录到Wi

    15、n2000/NT事件日志中/ param name=message需要记录的文本信息/param/ /summarypublic static void WriteWarning(String message)WriteLog(TraceLevel.Warning, message);/ summary/ 将提示信息记录到Win2000/NT事件日志中/ param name=message需要记录的文本信息/param/ /summarypublic static void WriteInfo(String message)WriteLog(TraceLevel.Info, message)

    16、;/ summary/ 将跟踪信息记录到Win2000/NT事件日志中/ param name=message需要记录的文本信息/param/ /summarypublic static void WriteTrace(String message)WriteLog(TraceLevel.Verbose, message);/ summary/ 格式化记录到事件日志的文本信息格式/ param name=ex需要格式化的异常对象/param/ param name=catchInfo异常信息标题字符串./param/ retvalue/ para格式后的异常信息字符串,包括异常内容和跟踪堆栈.

    17、/para/ /retvalue/ /summarypublic static String FormatException(Exception ex, String catchInfo)StringBuilder strBuilder = new StringBuilder();if (catchInfo != String.Empty)strBuilder.Append(catchInfo).Append(rn);strBuilder.Append(ex.Message).Append(rn).Append(ex.StackTrace);return strBuilder.ToString

    18、();/ summary/ 实际事件日志写入方法/ param name=level要记录信息的级别(error,warning,info,trace)./param/ param name=messageText要记录的文本./param/ /summaryprivate static void WriteLog(TraceLevel level, String messageText)tryEventLogEntryType LogEntryType;switch (level)case TraceLevel.Error:LogEntryType = EventLogEntryType.E

    19、rror;break;case TraceLevel.Warning:LogEntryType = EventLogEntryType.Warning;break;case TraceLevel.Info:LogEntryType = EventLogEntryType.Information;break;case TraceLevel.Verbose:LogEntryType = EventLogEntryType.SuccessAudit;break;default:LogEntryType = EventLogEntryType.SuccessAudit;break;EventLog e

    20、ventLog = new EventLog(Application, ApplicationConfiguration.EventLogMachineName, ApplicationConfiguration.EventLogSourceName );/写入事件日志eventLog.WriteEntry(messageText, LogEntryType);catch /忽略任何异常 /class ApplicationLog-12.Panel 横向滚动,纵向自动扩展asp:panel style=overflow-x:scroll;overflow-y:auto;/asp:panel-1

    21、3.回车转换成Tabscript language=javascript for=document event=onkeydownif(event.keyCode=13 & event.srcElement.type!=button & event.srcElement.type!=submit & event.srcElement.type!=reset & event.srcElement.type!=& event.srcElement.type!=textarea);event.keyCode=9;/scriptonkeydown=if(event.keyCode=13) event.

    22、keyCode=9-14.DataGrid超级连接列DataNavigateUrlField=字段名 DataNavigateUrlFormatString=http:/xx/inc/delete.aspx?ID=0-15.DataGrid行随鼠标变色private void DGzf_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)if (e.Item.ItemType!=ListItemType.Header)e.Item.Attributes.Add( onmouseout,th

    23、is.style.backgroundColor=+e.Item.StyleBACKGROUND-COLOR+);e.Item.Attributes.Add( onmouseover,this.style.backgroundColor=+ #EFF3F7+);-16.模板列ASP:TEMPLATECOLUMN visible=False sortexpression=demo headertext=IDITEMTEMPLATEASP:LABEL text=%# DataBinder.eval_r(Container.DataItem, ArticleID)% runat=server width=80% id=lblColumn /ITEMTEMPLATE/ASP:TEMPLATECOLUMNASP:TEMPLATECOLUMN headertext=选中HEADERSTYLE wrap=False horizontalalign=Center/HEADERSTYLEITEMTEMPLATEASP:CHECKBOX id=chkExport runat=server /ITEMTEMPLATEEDITI


    注意事项

    本文(技巧方法.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开