½÷É÷Asp.netÖÐstatic±äÁ¿µÄÓ÷¨
ÔÚ.Netƽ̨ϽøÐÐCSÈí¼þ¿ª·¢Ê±,ÎÒÃǾ³£Óöµ½ÒÔºó»¹ÒªÓõ½Ä³Ð©±äÁ¿ÉÏ´ÎÐ޸ĺóµÄÖµ,ΪÁ˼òµ¥Æð¼û,ºÜ¶àÈ˶¼Ï°¹ßÓÃstaticÀ´¶¨ÒåÕâЩ±äÁ¿,ÎÒÒ²ÊÇ¡£ÕâÑù·Ç³£·½±ã£¬ÏÂÒ»´Îµ÷ÓÃij¸öº¯Êýʱ¸Ã±äÁ¿ÈÔÈ»±£´æµÄÊÇ´¦Àí¹ýµÄÖµ£¬Ö±½ÓÄÃÀ´ÓþͿÉÒÔÁË¡£
ÏÖÔÚתÈëÁËBSÈí¼þ¿ª·¢£¬ÎÒÃǺÜ×ÔÈ»µØ»áÑØÓÃÕâÖÖÏ°¹ß¡£ÈçÔÚÒ³ÃæÖÐͳ¼Æij¸ö°´Å¥±»°´ÏµĴÎÊý£¬ÏÈÔÚÀàÖÐOnClickʼþµÄ´¦Àí¹ý³ÌÇ°¶¨ÒåÒ»static±äÁ¿times,Ôòÿ´Îµ÷Óøð´Å¥µÄOnClickʼþʱ£¬ÁîtimesÔö1¼´¿É£¬·Ç³£·½±ã£º
[C#]:
...
static int times=0;
...
private void Button1_Click(object sender,EventArgs e)
{
times++;
Label1.Text=times.ToString();
}
ÔÚÎÒÃÇÇìÐÒÈç´Ë·½±ãÖ®Ó࣬¾ÍδÔøÒâʶµ½ÎÒÃÇÒѾÂñÏÂÁËÒ»¿ÃÄÑÒÔ²ì¾õµÄ¶¨Ê±Õ¨µ¯¡£ÎªÊ²Ã´ÄÄ£¿
Õ⻹Ҫ´ÓAsp.netµÄÔËÐлúÖÆ̸Æð¡£ÔÚCSģʽÈí¼þ¿ª·¢¹ý³ÌÖУ¬ÎÒÃÇͨ³£²»»á¹ØÐÄÓ¦ÓóÌÐòÊÇÔÚÄÄÀïÔËÐеģ¬±äÁ¿´æ·ÅÔÚÄÄÀ¿Í»§¶Ë³ÌÐò¾ÍÔËÐÐÔÚ¿Í»§¶Ë£¬·þÎñÆ÷¶Ë³ÌÐò¾ÍÔËÐÐÔÚ·þÎñÆ÷¶Ë£¬Ò»°ãÇé¿öÏ£¬¶þÕß³ýÁËÊý¾Ý¿âÖеÄÊý¾ÝÍâ»ù±¾Ã»ÓÐÆäËû¹²ÏíµÄ¶«Î÷¡£ËùÒÔÕâʱ¿Í»§¶ËµÄÓû§´ó¿É·ÅÐĵÄʹÓÃstatic±äÁ¿£¬ÒòΪËüÃǾʹæ·ÅÔÚ¿Í»§¶Ë³ÌÐòÖС£
ÓÚÊÇÎÒÃǾÍÏ°¹ßµÄÔÚ×öBSģʽµÄÒ³ÃæʱҲÓÃstatic±äÁ¿£¬Êâ²»ÖªAsp.netÖеÄstaticÒѲ»Í¬ÓÚCSÖеÄstatic¡£ÔÒòºÜ¼òµ¥£¬¾ÍÊÇÒòΪÔÚAsp.netÖÐËùÓеÄÓû§½«Ê¹ÓÃͬһ¸östatic±äÁ¿¡£Õâ¾ÍÒâζ×Åÿһ¸öʹÓøÃÒ³ÃæµÄÓû§¶Ô¸Ã±äÁ¿µÄ²Ù×÷½«»áÓ°Ïìµ½ÆäËûÓû§¡£¾ÍÄÃÉÏÃæ¼ÆÊýÆ÷µÄÀý×ÓÀ´Ëµ£¬¼ÙÉètimes³õÊÔֵΪ0£¬ÒòΪ´ËʱֻÓÐÎÒÃÇ×Ô¼ºÔÚʹÓÃÕâ¸öÒ³Ã棬µ±È»²»»áÓÐʲôÎÊÌ⣬µ«Èç¹ûÓÐÁ½¸öÈËͬʱÁ¬½Óµ½Õâ¸öÒ³Ã棬Èç¹ûAµ¥»÷ÁËButton1Ò»´Î£¬ÔòBË¢ÐÂÒ³ÃæºóLabel1½«ÏÔʾ1,Èç¹ûBÔÙµ¥»÷Button1Ò»´Î£¬Ôòtimes±ä³É2£¬Á½¸öÈËË¢ÐÂÒ³Ãæºó¾Í³öÏÖÎÊÌâÁË£ºAºÍB¶¼»á˵£¬ÎÒÃ÷Ã÷Ö»µ¥»÷ÁËButton1Ò»´Î£¬ÔõôLabel1¾ÍÏÔʾÎÒµ¥»÷ÁËÁ½´ÎÄÄ£¿——Õâ¾ÍÊÇÒòΪÁ½¸öÈ˹²ÓõÄÊÇ·þÎñÆ÷ÉÏͬһ¸ötimes£¬ÈκÎÒ»¸öÈ˶ÔtimesµÄ²Ù×÷¶¼»áÔÚʹÓøÃÒ³ÃæµÄËûÈ˵Ää¯ÀÀÆ÷ÖбíÏÖ³öÀ´¡£ÎÊÌâ¾Í³öÔÚÕâÀï¡£
Ôõô°ìÄÄ£¿»¹ºÃ£¬³ýÁË´«Í³µÄAspÖеÄSession¶ÔÏóÍ⣬Asp.netÌṩÁËÒ»¸ö¸üºÃµÄViewState¶ÔÏó¡£ViewState¶ÔÏóÓÃÀ´±£´æÒ³ÃæÖеĸ
Ïà¹ØÎĵµ£º
//private string datapatch = ConfigurationSettings.AppSettings["acessconn"];//Êý¾Ý¿âµØÖ·
private string datapatch = "db/global.asa";//Êý¾Ý¿âµØÖ·
///
/// È¡µÃdataset
//
/// ²éѯÓï¾ä
///
public DataSet GetDataSet(string Commandtext)
{&nbs ......
public string ClearHtml(string HtmlStr)
{
string tmpStr = HtmlStr;
tmpStr = ReplaceHtml("&#[^>]*;", tmpStr, "");
tmpStr = ReplaceHtml("</?marquee[^>]*>", tmpStr, "");
tmpStr = ReplaceHtml("</?object[^>]*>", tmpStr, "");
tmpSt ......
public string getip()
{
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
......
Asp.netÖеÄÈÕÆÚ´¦Àíº¯Êý
//2007Äê4ÔÂ24ÈÕ
this.TextBox6.Text = System.DateTime.Now.ToString("D");
//2007-4-24
this.TextBox7.Text = System.DateTime.Now.ToString("d");
&nb ......
public void MyGetDepart()
{
string sSql = @"select DepartId,DepartName as 'Ç廪¸½ÖÐ',ParentId from sDepart";
DataTable table = CommClass.GetDataTable(sSql);//BoolDAL.DbHelper.GetDataTabl ......