ASP.NET程序中常用代码汇总(四) リンク: ASP.NET程序中常用代码汇总(四) – dotnet.csdn.net 团队blog (测试). 31. 当文件在不同目录下,需要获取数据库连接字符串(如果连接字符串放在Web.config,然后在Global.asax中初始化) 在Application_Start中添加以下代码: Application[“ConnStr“]=this.Context.Request.PhysicalApplicationPath+ConfigurationSettings. AppSettings[“ConnStr“].ToString(); 32.变量.ToString() 字符型转换 转为字符串 12345.ToString(“n“); //生成 12,345.00 12345.ToString(“C“); //生成 ¥12,345.00 12345.ToString(“e“); //生成 1.234500e+004 12345.ToString(“f4“); //生成 12345.0000 12345.ToString(“x“); //生成 3039 (16进制) 12345.ToString(“p“); //生成 1,234,500.00% 33.变量.Substring(参数1,参数2); 截取字串的一部分,参数1为左起始位数,参数2为截取几位。 如:string s1 = str.Substring(0,2); 34.在自己的网站上登陆其他网站:(如果你的页面是通过嵌套方式的话,因为一个页面只能有一个FORM,这时可以导向另外一个页面再提交登陆信息) <SCRIPT language=”javascript”> <!– function gook(pws) { frm.submit(); } //–> </SCRIPT> <body leftMargin=”0″ topMargin=”0″ onload=”javascript:gook()” marginwidth=”0″… Read More
ASP.NET程序中常用代码汇总(三) リンク: ASP.NET程序中常用代码汇总(三) – dotnet.csdn.net 团队blog (测试). 31. 当文件在不同目录下,需要获取数据库连接字符串(如果连接字符串放在Web.config,然后在Global.asax中初始化) 在Application_Start中添加以下代码: Application[“ConnStr“]=this.Context.Request.PhysicalApplicationPath+ConfigurationSettings. AppSettings[“ConnStr“].ToString(); 32.变量.ToString() 字符型转换 转为字符串 12345.ToString(“n“); //生成 12,345.00 12345.ToString(“C“); //生成 ¥12,345.00 12345.ToString(“e“); //生成 1.234500e+004 12345.ToString(“f4“); //生成 12345.0000 12345.ToString(“x“); //生成 3039 (16进制) 12345.ToString(“p“); //生成 1,234,500.00% 33.变量.Substring(参数1,参数2); 截取字串的一部分,参数1为左起始位数,参数2为截取几位。 如:string s1 = str.Substring(0,2); 34.在自己的网站上登陆其他网站:(如果你的页面是通过嵌套方式的话,因为一个页面只能有一个FORM,这时可以导向另外一个页面再提交登陆信息) <SCRIPT language=”javascript”> <!– function gook(pws) { frm.submit(); } //–> </SCRIPT> <body leftMargin=”0″ topMargin=”0″ onload=”javascript:gook()” marginwidth=”0″… Read More
ASP.NET程序中常用代码汇总(二) 11.自定义异常处理 //自定义异常处理类 using System; using System.Diagnostics; namespace MyAppException { /**//// <summary> /// 从系统异常类ApplicationException继承的应用程序异常处理类。 /// 自动将异常内容记录到Windows NT/2000的应用程序日志 /// </summary> public class AppException:System.ApplicationException { public AppException() { if (ApplicationConfiguration.EventLogEnabled)LogEvent(“出现一个未知错误。“); } public AppException(string message) { LogEvent(message); } 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;… Read More
ASP.NET程序中常用代码汇总(一) リンク: ASP.NET程序中常用代码汇总(一) – dotnet.csdn.net 团队blog (测试). 1. 打开新的窗口并传送参数: //传送参数: response.write(“<script>window.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;}else{return false;}“) 3.删除表格选定记录 int intEmpID = (int)MyDataGrid.DataKeys[e.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 ListItemType.AlternatingItem… Read More
ASP.NET Web Parts Pages リンク: ASP.NET Web Parts Pages. リンク: WebParts Communication: How WebParts on a page communicate with each other.… Read More
Enterprise .NET Community: Creating a Custom ASP.NET Profile Provider リンク: Enterprise .NET Community: Creating a Custom ASP.NET Profile Provider. ASP.NET 2.0 is a compelling platform for most Web sites. The inclusion of many of the basic facilities that most Web sites will need like the ability to have members, keep profile information on those members and use role-based authorization, makes ASP.NET 2.0 an easy… Read More
Ajax in ASP.NET リンク: Ajax.NET Professional Examples. Microsoft.NET Framework 2.0 Below you will find some example web pages that are using Ajax.NET to get rid of the postback in typical ASP.NET applications: Class Example DataType Example DataSets Example HtmlControls Example Collections Example Special Example OnLoading Example KeyPress Example UserControls Example I added a Quick Guide to get the… Read More
ASP.NET Spiced: AJAX リンク: User Interface. Karl Seguin September 2005 Applies to: AJAX (Asynchronous JavaScript And XML) Microsoft AJAX.NET Microsoft ASP.NET Summary: Learn how AJAX (Asynchronous JavaScript And XML) can be used to make your Microsoft ASP.NET applications more dynamic and responsive. (17 printed pages) Download the code sample for this article, AjaxASPNETCS.msi in C#… Read More
ONDotnet.com: Localization in ASP.NET 2.0 リンク: ONDotnet.com: Localization in ASP.NET 2.0. Published on ONDotNet.com (http://www.ondotnet.com/) http://www.ondotnet.com/pub/a/dotnet/2005/08/08/localizingaspnet20.html See this if you’re having trouble printing code examples Localization in ASP.NET 2.0 by Wei-Meng Lee 08/08/2005 The Web is an international place. Why shouldn’t your websites be ready for international visitors? Isn’t that was the first two Ws (”World” … Read More
Web Parts リンク: Fredrik Norm�n’s blog – NSQUARED2. I have implemented a new feature for the WebPart feature shipped with ASP.Net 2.0. The new feature is an extended PropertyGridEditorPart where you can build your own editor control for the properties. If you use a PropertyGrdiEditorPart, all properties will be displayed within the edit part as a TextBox,… Read More