Asp.net使用技巧(译)
原文地址:http://scottwater.com/blog/archive/quick-tips-for-asp-net-part-one/
1.Do not use the AutoPostBack attribute on the DropDownList control to simply
使用客户端代码来完成功能
2.Never use the ASP.Net Label control.
Label会附加额外不利于样式的代码, 使用Literal代替.
3.Use the ASP.Net Repeater instead of DataList, DataGrid, and DataView controls
4.Understand how to effectively use caching
内存很珍贵 不要过度使用缓存.
5.Always set a memory threshold for your AppPool.
为应用程序池设定内存大小.
6.Use AppOffline.htm for updates
发布程序时,使用AppOffline.htm作为临时的页面.
7.Always check Page.IsValid in your button's EventHandler.
一切的输入都是有害的
8.To create fully qualified URLs, use the new VirtualPath class.
使用VirtualPathUtility创建合格的URL
1.Do not use the AutoPostBack attribute on the DropDownList control to simply
使用客户端代码来完成功能
<asp:DropDownList runat="Server" ID = "dropdown" onchange = "if(this.selectedIndex > 0)
{ window.location = window.location.pathname + '?t=' + this[this.selectedIndex].value;}" />
{ window.location = window.location.pathname + '?t=' + this[this.selectedIndex].value;}" />
2.Never use the ASP.Net Label control.
Label会附加额外不利于样式的代码, 使用Literal代替.
3.Use the ASP.Net Repeater instead of DataList, DataGrid, and DataView controls
4.Understand how to effectively use caching
内存很珍贵 不要过度使用缓存.
5.Always set a memory threshold for your AppPool.
为应用程序池设定内存大小.
6.Use AppOffline.htm for updates
发布程序时,使用AppOffline.htm作为临时的页面.
7.Always check Page.IsValid in your button's EventHandler.
一切的输入都是有害的
8.To create fully qualified URLs, use the new VirtualPath class.
使用VirtualPathUtility创建合格的URL
string relativePath = "~/somefolder/test/123.aspx"
Uri newUri = new Uri(Request.Url, VirtualPathUtility.ToAbsolute(relativePath));
Uri newUri = new Uri(Request.Url, VirtualPathUtility.ToAbsolute(relativePath));
