ASP.NET µÄһЩ³£Óü¼Çɱ¸Íü1
1 »ñÈ¡´íÎóÐÅÏ¢²¢µ½Ö¸¶¨Ò³Ã治ҪʹÓÃ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µÄ²úÉú´Ó¶ø¶ªÊ§ÁË´íÎóÐÅÏ¢£¬
ËùÒÔÒ³Ãæµ¼ÏòÓ¦¸ÃÖ±½ÓÔÚ·þÎñÆ÷¶ËÖ´ÐУ¬ÕâÑù¾Í¿ÉÒÔÔÚ´íÎó´¦ÀíÒ³ÃæµÃµ½³ö´íÐÅÏ¢²¢½øÐÐÏàÓ¦µÄ´¦Àí.
2 Çå¿ÕCookie
Cookie.Expires=[DateTime];
Response.Cookies("UserName").Expires = 0
3 »Ø³µ×ª»»³ÉTab
<script language="javascript" for="document" event="onkeydown">
¡¡if(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;
</script>
onkeydown="if(event.keyCode==13) event.keyCode=9"
4 Ϊ°´Å¥Ìí¼Ó¶Ô»°¿ò
Button1.Attributes.Add("onclick","return confirm(’È·ÈÏ?’)");
button.attributes.add("onclick","if(confirm(’are you sure...?’)){return
true;}else{return false;}")
5 ¶ÁÈ¡DataGrid¿Ø¼þTextBoxÖµ
foreach(DataGrid dgi in yourDataGrid.Items)
{
¡¡TextBox tb = (TextBox)dgi.FindControl("yourTextBoxId");
¡¡tb.Text....
}
6 ×Ö·ûÐÍת»» תΪ×Ö·û´®
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%
Ïà¹ØÎĵµ£º
1. Get(¼´Ê¹ÓÃQueryStringÏÔʽ´«µÝ)
·½Ê½£ºÔÚurlºóÃæ¸ú²ÎÊý¡£
Ìص㣺¼òµ¥¡¢·½±ã¡£
ȱµã£º×Ö·û´®³¤¶È×Ϊ255¸ö×Ö·û£»Êý¾Ýй©ÔÚurlÖС£
ÊÊÓÃÊý¾Ý£º¼òµ¥¡¢ÉÙÁ¿¡¢¹Ø¼üµÄÊý¾Ý¡£
ÊÊÓ÷¶Î ......
1. Web.configÖÐÌí¼Ó:
<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
2. 頁ÃæÖÐÌí¼Ó:
<head>
<meta http-equiv="Content-Type" content="charset=utf-8&qu ......
Ò»¡¢ÈÏʶWeb.configÎļþ
Web.config ÎļþÊÇÒ»¸öXMLÎı¾Îļþ£¬ËüÓÃÀ´´¢´æ ASP.NET Web Ó¦ÓóÌÐòµÄÅäÖÃÐÅÏ¢£¨Èç×î³£ÓõÄÉèÖÃASP.NET Web Ó¦ÓóÌÐòµÄÉí·ÝÑéÖ¤·½Ê½£©£¬Ëü¿ÉÒÔ³öÏÖÔÚÓ¦ÓóÌÐòµÄÿһ¸öĿ¼ÖС£µ±Äãͨ¹ý.NETн¨Ò»¸öWebÓ¦ÓóÌÐòºó£¬Ä¬ÈÏÇé¿öÏ»áÔÚ¸ùĿ¼×Ô¶¯´´½¨Ò»¸öĬÈ쵀 Web.configÎļþ£¬°üÀ¨Ä¬ÈϵÄÅäÖÃÉèÖ㬠......
If Óï¾äÔÚASP.NETÖеÄÓ¦ÓÃ
ÔÚASP.NETÖÐÓÐÐí¶àµØ·½ÒªÓõ½“ifÓï¾ä”£¬ÆäʵifÓï¾äÊÇC# ·ÖÖ§½á¹¹ ÖеÄÒ»ÖÖ¡£
·ÖÖ§½á¹¹ÊÇÓÐÌõ¼þµÄÖ´ÐдúÂ룬¿ØÖÆÏÂÒ»²½ÒªÖ´ÐÐÄÄЩ´úÂëµÄ¹ý³Ì¡£
·ÖÖ§½á¹¹£º
1£®ifÓï¾ä
2£®SwitchÓï¾ä
½ñÌìËù½²µÄÄÚÈÝΪif Óï¾ä£º
Ê×ÏÈC#ÖÐif½á¹¹µÄÓï·¨ÈçÏ£º
If (±í´ïʽ)
{
´úÂë¿ ......
ASP.NET 4µÄWeb Formsµ±ÖУ¬×îÁîÈ˼¤É͵ģ¬ÔòĪ¹ýÓÚÊÇURL Routing»úÖƵÄÈ«ÃæÖ§³Ö¡£¹ýÈ¥ÔÚASP.NET 3.5 SP1µ±ÖУ¬Web Forms»ò¶à»òÉپͿªÊ¼Ö§³ÖURL Routing»úÖÆ£¬ËüÈÃÎÒÃÇÔÚÍøÖ·µÄ³ÊÏÖÒÔ¼°Ê¹ÓÃÉϸü¼ÓµÄÓе¯ÐÔ¡£
¹ýÈ¥ÎÒÃÇÔÚASP.NETµ±ÖУ¬Ï°¹ßÓÚµ×ÏÂÕâÑùµÄÍøÖ·³ÊÏÖ·½Ê½£º
http://myWebSite/EditProduct.aspx?Id=1
µ«×î½ü¼¸ÄêR ......