ASP.NET note I
Page_Load--Ò³Ãæ¼ÓÔØÊ¼þ.
Page.IspostBackÅжÏÊÇ·ñµÚÒ»´Î¼ÓÔØ¡£
ÿ´ÎÏìÓ¦·þÎñÐÅÏ¢(¼È¿Í»§ÇëÇóASP.NETÒ³Ãæ-ASPXÎļþ»òWeb·þÎñ-
ASMXÎļþ)¾Í¼ÓÔØÒ»´Î(Ö´ÐÐÒ»´ÎPage_Load)¡£
¼ÓÔØµÄʱºò²¢²»ÊÇÿ´Î¶à±àÒëÒ»´Î´úÂëÎļþ£¬ÒòΪ£ºÃ¿Ò»´ÎÇëÇó
ASPXÎļþʱ²¢²»ÊǶàÒª½øÐÐÒ»´Î±àÒ룬¶øÊǵÚÒ»´ÎÖ´ÐÐASP.NETÒ³ÃæµÄ
½á¹ûÊÇ£ºÒ³Ãæ±»±àÒë³É»úÆ÷´úÂ룬¶øÇÒ±»ÔØÈëµ½.netÔËÐÐʱ¼äµÄÈ«¾Ö³Ì
Ðò¼¯»º´æ(GAC)µ±ÖУ¬ÕâÑù¾ÍΪÆäËûµÄÍйÜÓ¦ÓóÌÐòµÄʹÓÃ×öºÃÁË×¼±¸
¡£Ö»ÓÐÔÚ´úÂë·¢Éú¸Ä¶¯(»òÕßÖØÐÂÆô¶¯ÁËWeb·þÎñÆ÷»ò¼ÆËã»ú)ʱ£¬ASPX
Ò³Ãæ²ÅÐèÒªÖØÐ±àÒë¡£
-----------------------------------------
¸½£º ±àÒëµÄ¹ý³Ì£ºÔÚ±àÒëʹÓÃ.net framwork¿âµÄ´úÂëʱÏÈÊDZàÒë³É
MSILÖмäÓïÑÔ£¬È»ºó°ÑMSIL±àÒë³É»úÆ÷´úÂë-ʵʱ±àÒë(just-in-
time,JIT)¡£ ***ʵʱ±àÒë-ËûÄÜʹӦÓóÌÐò×é¼þÖ»ÓÐÔÚÓ¦ÓóÌÐòÐèÒªËû
ÃǵÄʱºò²Å±»±àÒë¡£
-----------------------------------------
Ïà¹ØÎĵµ£º
1.Á¬½ÓÊý¾Ý¿âÎļþ
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;AttachDBFilename=|DataDirectory|TimeTracker.mdf;User Instance=true" />
SqlConnectionStringBuilderʵÀý»¯Ê±£¬ÒªÓõ½connectionString£¬È磺SqlConnectionStringBuild builder = new SqlC ......
ASP.NET ÌṩÈýÖÖÓÃÓÚÔÚ³öÏÖ´íÎóʱ²¶»ñºÍÏìÓ¦´íÎóµÄÖ÷Òª·½·¨£ºPage_Error ʼþ¡¢Application_Error ʼþÒÔ¼°Ó¦ÓóÌÐòÅäÖÃÎļþ (Web.config)¡£
Èç¹ûÄú²»µ÷Óà Server.ClearError »òÕß²¶»ñ Page_Error »ò Application_Error ʼþÖеĴíÎó£¬Ôò½«¸ù¾Ý Web.config ÎļþµÄ <customErrors> ²¿·ÖÖеÄÉèÖô¦Àí´íÎó¡£ÔÚ & ......
ʹÓà SqlDataSource ¿Ø¼þÖ»ÐèºÜÉٵĴúÂë»òÎÞÐèÈκδúÂë¼´¿É´ÓÊý¾Ý¿âÖмìË÷Êý¾Ý¡£SqlDataSource ¿Ø¼þ¿ÉÓÃÓÚÈκξßÓйØÁª ADO.NET Ìṩ³ÌÐò£¨ÔÚÅäÖÃÎļþµÄ DbProviderFactories ½ÚÖÐÅäÖ㩵ÄÊý¾Ý¿â£¬°üÀ¨ Microsoft SQL Server¡¢Oracle¡¢ODBC »ò OLE DB Êý¾Ý¿â£¨Èç Microsoft Access£©¡£ÄúÔÚÅäÖÃʱָ¶¨ SqlDataSource ʹÓõ ......
////½ñÌìÔÚÐ޸ijÌÐòµÄʱºò·¢ÏÖÒ»¸öСµÄÎÊÌâÌØ¼Ç¼ÈçÏÂ:
//////ÓÐʱºòdatetimeÎÞ·¨×ª³Éstring£¬¿ÉÒÔÓÃgetdate()Ö±½Ó²åÈë¾Í¿ÉÒÔÁË
string str = "update adaddress set shenhe=" + ck + " ,shentime=getDate() where id=" + uid + "";
/////////////////////////////////////////
ÒÔϾßÌå½éÉÜÈÕÆÚÔõÑùת»»
DateTime.Now ......
1¡¢ÔÚÒ³Ãæ¶¯Ì¬Ìí¼ÓÒ»¸ö¿Ø¼þµÄ·½·¨¡£ ÔÚÒ³ÃæµÄ HTML ´úÂëÉÏÉèÖÃÒ»¸ö asp:PlaceHolder վλ¿Ø¼þ£¬µ±Ò³Ãæ±»¼ÓÔØµÄʱºò£¬ÔÚÕâ¸ö PlaceHolder ¿Ø¼þÉÏÌí¼ÓËùÐèÒªµÄÆäËû¿Ø¼þ¡£
<asp:PlaceHolder runat="server" id="PutLabelHere" /> Sub Page_Load(sender as Object, e ......