21¸öAsp.Net¾³£»áÓõ½µÄº¯Êý¼¯
1¡¢DateTime Êý×ÖÐÍ
System.DateTime currentTime=new System.DateTime();
1.1 È¡µ±Ç°ÄêÔÂÈÕʱ·ÖÃë
currentTime=System.DateTime.Now;
1.2 È¡µ±Ç°Äê
int Äê=currentTime.Year;
1.3 È¡µ±Ç°ÔÂ
int ÔÂ=currentTime.Month;
1.4 È¡µ±Ç°ÈÕ
int ÈÕ=currentTime.Day;
1.5 È¡µ±Ç°Ê±
int ʱ=currentTime.Hour;
1.6 È¡µ±Ç°·Ö
int ·Ö=currentTime.Minute;
1.7 È¡µ±Ç°Ãë
int Ãë=currentTime.Second;
1.8 È¡µ±Ç°ºÁÃë
int ºÁÃë=currentTime.Millisecond;
£¨±äÁ¿¿ÉÓÃÖÐÎÄ£©
2¡¢Int32.Parse(±äÁ¿) Int32.Parse("³£Á¿")
×Ö·ûÐÍת»» תΪ32λÊý×ÖÐÍ
3¡¢ ±äÁ¿.ToString()
×Ö·ûÐÍת»» תΪ×Ö·û´®
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%
4¡¢±äÁ¿.Length Êý×ÖÐÍ
È¡×Ö´®³¤¶È£º
È磺 string str="Öйú";
int Len = str.Length ; //LenÊÇ×Ô¶¨Òå±äÁ¿£¬ strÊÇÇó²âµÄ×Ö´®µÄ±äÁ¿Ãû
5¡¢System.Text.Encoding.Default.GetBytes(±äÁ¿)
×ÖÂëת»» תΪ±ÈÌØÂë
È磺byte[] bytStr = System.Text.Encoding.Default.GetBytes(str);
È»ºó¿ÉµÃµ½±ÈÌس¤¶È£º
len = bytStr.Length;
6¡¢System.Text.StringBuilder("")
×Ö·û´®Ïà¼Ó£¬£¨+ºÅÊDz»ÊÇÒ²Ò»Ñù£¿£©
È磺System.Text.StringBuilder sb = new System.Text.StringBuilder("");
sb.Append("Öлª");
sb.Append("ÈËÃñ");
sb.Append("¹²ºÍ¹ú");
7¡¢±äÁ¿.Substring(²ÎÊý1,²ÎÊý2);
½ØÈ¡×Ö´®µÄÒ»²¿·Ö£¬²ÎÊý1Ϊ×óÆðʼλÊý£¬²ÎÊý2Ϊ½ØÈ¡¼¸Î»¡£
È磺string s1 = str.Substring(0,2);
8¡¢String user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString();
È¡Ô¶³ÌÓû§IPµØÖ·
9¡¢´©¹ý´úÀí·þÎñÆ÷È¡Ô¶³ÌÓû§ÕæʵIPµØÖ·£º
if(Request.ServerVariables["HTTP_VIA"]!=null){
string user_IP=Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}else{
string user_IP=Request.ServerVariables["REMOTE_ADDR"].ToString();
}
10¡¢ Session["±äÁ¿"];
´æÈ¡SessionÖµ£»
È磬¸³Öµ£º Session["username"]="С²¼Ê²";
È¡Öµ£º Object objName=Session["username"];
String strName=objName.ToString();
Çå¿Õ
Ïà¹ØÎĵµ£º
·þÎñÆ÷¿Ø¼þÉúÃüÖÜÆÚ¼ò½é
¡¡¡¡·þÎñÆ÷¿Ø¼þµÄÉúÃüÖÜÆÚÊÇ´´½¨·þÎñÆ÷¿Ø¼þ×îÖØÒªµÄ¸ÅÄî¡£×÷Ϊ¿ª·¢ÈËÔ±£¬±ØÐë¶Ô·þÎñÆ÷¿Ø¼þÉúÃüÖÜÆÚÉî¿ÌÀí½â¡£µ±È»£¬Õâ²»ÊÇÒ»³¯Ò»Ï¦¾Í¿ÉÒÔ×öµ½µÄ¡£¶ÔÓÚѧϰ
¿Ø¼þ¿ª·¢¼¼ÊõµÄ³õѧÕߣ¬¿ÉÒÔ²»±ØÕÆÎյ÷dz£ÏêϸÉîÈ룬ֻÐè¶Ô·þÎñÆ÷¿Ø¼þµÄÉúÃüÖÜÆÚÖеIJ»Í¬½×¶ÎÓÐÒ»¸ö´óÖµÄÁ˽⼴¿É¡£
¡¡ ......
ÔÚÏÖÔÚµÄÍøÕ¾Éè¼ÆÖУ¬¸üÇ¿µ÷µÄÊÇÓû§µÄ¸öÐÔ»¯ÉèÖã¬ÈÃÓû§¿ÉÒÔ×ÔÓɵÄÉèÖ÷ûºÏ×Ô¼ºÏ²ºÃµÄÒ³Ãæ³ÉΪÍøÕ¾¿ª·¢ÈËÔ±µÄÍ·ºÅÄÑÌ⣬²»¹ýÏÖÔÚ¿´À´Õâ¸öÄÑÌâ΢Èí°ïÎÒÃǽâ¾öÁË¡£ÔÚasp.net 2.0ÖÐÐÂÔö¼ÓÁËһϵÁÐwebpart¿Ø¼þ£¬¿ÉÒÔÈÃÓû§ºÜ·½±ãµØ¶ÔÍøÒ³µÄ¸÷ÇøÓò²¼¾Ö½øÐе÷Õû¡£ÔÚһЩwebÓ¦ÓóÌÐòÖУ¬Èç¹ûÓû§Ïë×Ô¶¨ÒåÒ³Ãæ²¼¾Ö£¬±ÈÈçÒ»¸öÐÂÎÅ· ......
ASP.NETÖУ¬¾³£»áʹÓõ½templates(Ä£°æ)¹¦ÄÜ£¬±ÈÈçÔÚdatagrid£¬datalist£¬repeaterµÈ¿Ø¼þÖУ¬Ê¹ÓÃtemplates£¬½«»á´ó´óÔöÇ¿Æ书ÄÜ¡£ÒÔÍù£¬ÎÒÃÇÒ»°ãÊÇÔÚÉè¼Æ³ÌÐòʱ£¬¾ÍÒѾÉèÖúÿؼþÖеÄÄ£°æÊÇÔõÑùµÄÁË¡£µ«ÊÇ£¬ÓеÄʱºò£¬¿ÉÄÜÎÒÃÇÐèÒª¶¯Ì¬¼ÓÔØÄ£°æ£¬±ÈÈ磬µ±ÄãÒªÇóÄãµÄÓ¦ÓóÌÐòµÄ½çÃæ·ç¸ñËæ×ÅÓû§µÄÐèÇó¶ø±ä»¯Ê±£¬Äã¾ÍÐèÒ ......
¾¡Ô绺´æ;¾³£»º´æ ÄúÓ¦¸ÃÔÚÓ¦ÓóÌÐòµÄÿһ²ã¶¼ÊµÏÖ»º´æ¡£ÏòÊý¾Ý²ã¡¢ÒµÎñÂß¼²ã¡¢UI »òÊä³ö²ãÌí¼Ó»º´æÖ§³Ö¡£ÄÚ´æÏÖÔڷdz£±ãÒË — Òò´Ë£¬Í¨¹ýÒÔÖÇÄܵķ½Ê½ÔÚÕû¸öÓ¦ÓóÌÐòÖÐʵÏÖ»º´æ£¬¿ÉÒÔ»ñµÃºÜ´óµÄÐÔÄÜÌá¸ß¡£ »º´æ¿ÉÒÔÑÚ¸ÇÐí¶à¹ýʧ»º´æÊÇÒ»ÖÖÎÞÐè´óÁ¿Ê±¼äºÍ·ÖÎö¾Í¿ÉÒÔ»ñµÃ“×ã¹»Á¼ºÃµ ......