asp.net(c#) static¹Ø¼ü×ÖÓ÷¨Ð¡½á[zz]
http://ayic1.blog.163.com/blog/static/27343030200965103528805/
¾²Ì¬±äÁ¿
µ±ÎÒÃDZàдһ¸öÀàʱ£¬Æäʵ¾ÍÊÇÔÚÃèÊöÆä¶ÔÏóµÄÊôÐÔºÍÐÐΪ£¬¶ø²¢Ã»ÓвúÉúʵÖÊÉϵĶÔÏó£¬Ö»ÓÐͨ¹ýnew¹Ø¼ü×ֲŻá²úÉú³ö¶ÔÏó£¬Õâʱϵͳ²Å»á·ÖÅäÄÚ´æ¿Õ¼ä¸ø¶ÔÏó£¬Æä·½·¨²Å¿ÉÒÔ¹©Íⲿµ÷Óá£
ÓÐʱºò£¬ÎÒÃÇÏ£ÍûÎÞÂÛÊÇ·ñ²úÉúÁ˶ÔÏó»òÎÞÂÛ²úÉúÁ˶àÉÙ¶ÔÏóµÄÇé¿öÏ£¬Ä³Ð©Ìض¨µÄÊý¾ÝÔÚÄÚ´æ¿Õ¼äÀïÖ»ÓÐÒ»·Ý£¬ÀýÈçËùÓеÄÖйúÈ˶¼Óйú¼ÒÃû³Æ£¬Ã¿Ò»¸öÖйúÈ˶¼¹²ÏíÕâ¸ö¹ú¼ÒÃû³Æ£¬²»±ØÔÚÿһ¸öÖйúÈ˵ÄʵÀý¶ÔÏóÖж¼µ¥¶À·ÖÅäÒ»¸öÓÃÓÚ´úÂë¹ú¼ÒÃû³ÆµÄ±äÁ¿¡£Àý×Ó£º
protected void Page_Load(object sender, EventArgs e)
{
//Ö±½ÓʹÓÓÀàÃû.³ÉÔ±”µÄ¸ñʽ£¬²»ÄÜʹÓÓ¶ÔÏóÃû.³ÉÔ±”µÄ¸ñʽ£¬ÕâµãÓëJAVA²»Ò»Ñù£¬JAVAÁ½ÖÖ¶¼¿ÉÒÔʹÓÃ
Response.Write(Chinese.Country);
}
class Chinese
{
public static string Country = "Öйú";
public void getCountry()
{
//ÀàÖеijÉÔ±·½·¨Ò²¿ÉÒÔÖ±½Ó·ÃÎʾ²Ì¬³ÉÔ±±äÁ¿
HttpContext.Current.Response.Write("ÄãºÃ£¡" + Country);
}
}
ÐèҪעÒâµÄÊÇ£º²»ÄÜ°ÑÈκη½·¨ÌåÄڵıäÁ¿ÉùÃ÷Ϊ¾²Ì¬£¬ÈçÏÂÃæÕâÑùÊDz»Ðеģº
public void getCountry()
{
//ÀàÖеijÉÔ±·½·¨Ò²¿ÉÒÔÖ±½Ó·ÃÎʾ²Ì¬³ÉÔ±±äÁ¿
HttpContext.Current.Response.Write("ÄãºÃ£¡" + Country);
static int i = 1;
}
¾²Ì¬·½·¨
ÎÒÃÇÓÐʱҲϣÍû²»±Ø´´½¨¶ÔÏó¾Í¿ÉÒÔµ÷ÓÃij¸ö·½·¨£¬»»¾ä»°ËµÒ²¾ÍÊÇʹ¸Ã·½·¨²»±ØºÍ¶ÔÏó°ó¶¨ÔÚÒ»Æð¡£ÒªÊµÏÖÕâÑùµÄЧ¹û£¬Ö»ÐèÒªÔÚÀàÖж¨ÒåµÄ·½·¨Ç°¼ÓÉÏstatic¹Ø¼ü×־ͿÉÒÔÁË£¬ÎÒÃdzÆÕâÖÖ·½·¨Îª¾²Ì¬³ÉÔ±·½·¨£¬»¹¿ÉÒÔÔÚÀàµÄ·Ç¾²Ì¬³ÉÔ±·½·¨ÖÐÏó·ÃÎÊÆäËû¾²Ì¬·½·¨Ò»ÑùÈ¥·ÃÎÊÕâ¸ö¾²Ì¬·½·¨£¬Àý×Ó£º
prot
Ïà¹ØÎĵµ£º
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯¡¡
¡¡
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕÊ±Ê ......
ǰ̨ aspx Îļþ:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="List.aspx.cs" Inherits="List" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<he ......
__________________________________________________________
¼øÓÚ¹ã´óȺÖÚÒâ¼û£¬½áÌû£¬²»ÔÙ¶¥Æð¡£
¸Ðл¥Ö÷µÄ·ÖÏí¡£
by Öñ×Ó°æÖ÷
__________________________________________________________
¡¾Ç°Ðò¡¿
ASP.NET³£ÓÃÓï¾ä1--20Ìõ
ASP.NET³£ÓÃÓï¾ä21-26Ìõ
27.Êý×Ö¸ñʽ»¯
¡¾£¼%#Container.DataItem(&q ......
1.Application£ºÓÃÓÚ±£´æËùÓÐÓû§¹²ÓõÄÊý¾ÝÐÅÏ¢¡£ ÔÚAsp.NetÖÐÀàËƵÄÅäÖÃÊý¾Ý×îºÃ±£´æÔÚWeb.configÎļþÖС£Èç¹ûʹÓÃApplication¶ÔÏó£¬Ò»¸öÐèÒª¿¼ÂǵÄÎÊÌâÊÇÈκÎд²Ù×÷¶¼ÒªÔÚ Application_OnStartʼþ£¨global.asax£©ÖÐÍê³É¡£¾¡¹ÜʹÓÃApplication.LockºÍ Application.Unlock·½·¨À´±ÜÃâд²Ù×÷µÄͬ²½£¬µ«ÊÇËü´®Ðл¯ÁËApplicat ......
ÔÚÓÃGridView¿Ø¼þʱ£¬ÎÒÃǾ³£»áÅöµ½»ñÈ¡µ±Ç°ÐеÄË÷Òý£¬Í¨¹ýË÷Òý½øÐÐÐí¶à²Ù×÷¡£ÀýÈ磬¿ÉÒÔ»ñµÃµ±Ç°ÐÐijһ¸ö¿Ø¼þÔªËØ£»ÉèÖÃijһԪËصÄÖµµÈµÈ¡£
ÏÂÃæ½áºÏʵÀý½éÉܼ¸ÖÖ»ñµÃGridViewµ±Ç°ÐÐË÷ÒýÖµµÄ·½·¨¡£
ʵÀý£º
¢Ù Ä¿µÄ£º»ñÈ¡GridViewÖÐRowCommandµÄµ±Ç°Ë÷ÒýÐС£
¢Ú ǰ̨ҳÃ棺ÔÚGridViewÖÐÌí¼Óһģ°æÁУ¬ÀïÃæÌí¼ÓÒ»¸öLink ......