ASP.NET ¼¼ÇÉƪ
Asp.NetÖм¸ÖÖÏàËƵıê¼Ç·ûºÅ: < %=...%>< %#... %>< % %>< %@ %>½âÊͼ°Ó÷¨
´ð: < %#... %>: ÊÇÔڰ󶨿ؼþDataBind()·½·¨Ö´ÐÐʱ±»Ö´ÐУ¬ÓÃÓÚÊý¾Ý°ó¶¨
Èç: < %# Container.DataItem("tit") %>
< %= %>: ÔÚ³ÌÐòÖ´ÐÐʱ±»µ÷Ó㬿ÉÒÔÏÔʾºǫ́±äÁ¿Öµ
Èç:
*.aspxÖУº < %= aaa %>
*.csÖÐ: protected string aaa="ÐÕÃû";
< % %>: ÄÚÁª´úÂë¿éÀïÃæ¿ÉÒÔÔÚÒ³ÃæÎļþ*.aspx»ò*.ascxÎļþÀïÃæǶÈëºǫ́´úÂë
Èç:
< %
for(int i=0;i<100;i++)
{
Reaponse.Write(i.ToString());
}
%>
< %@ %>ÊÇÔÚ*.aspxÒ³Ãæǰ̨´úÂëµ¼ÈëÃüÃû¿Õ¼ä,
Èç:
< %@ Import namespace="System.Data"%>
2.¿Ø¼þ½ÓÊÕÄÄЩÀàÐÍÊý¾Ý?
´ð:½ÓÊÕBindµÄ¿Ø¼þ£¬Ò»°ãÓÐDropDownList,DataList,DataGrid,ListBoxÕâЩ¼¯ºÏÐÔÖʵĿؼþ£¬¶ø±»À¦°ó
µÄÖ÷ÒªÊÇArrayList(Êý×é),Hashtable(¹þÏ¡±í),DataView(Êý¾ÝÊÓͼ),DataReaderÕâËĸö£¬ÒÔºóÎÒÃǾͿÉÒÔ
¶ÔºÅÈë×ù£¬²»»á³öÏÖDataTable±»À¦°óµÄ´íÎóÁË£º£©
3.DataBind,»ñµÃµÄÊý¾Ý£¬ÏµÍ³»á½«ÆäĬÈÏΪString,ÔõÑùת»¯ÎªÆäËüµÄÀàÐÍ?
DataBinder.Eval(Container.DataItem,"ת»»µÄÀàÐÍ","¸ñʽ")
×îºóÒ»¸ö"¸ñʽ"ÊÇ¿ÉÑ¡µÄ£¬Ò»°ã²»ÓÃÈ¥¹ÜËû£¬Container.DataItemÊÇÀ¦°óµÄÊý¾ÝÏî,"ת»»ÀàÐÍ"Ö¸µÄÊÇ Integer,String,BooleanÕâÒ»ÀණÎ÷.
4.Ö÷ÒªÃüÃû¿Õ¼ä:
< % @ Import Namespace="System.Data" %> ´¦ÀíÊý¾ÝʱÓõ½
< % @ Import Namespace="System.Data.ADO" % > ʹÓÃADO.net ; ʱÓõ½
< % @ Import Namespace="System.Data.SQL" %> SQL Server Êý¾Ý¿âרÓÃ
< % @ Import Namespace="System.Data.XML" %> ²»Óÿ´´¦ÀíXMLÓõ½
< % @ Import Namespace="System.IO" %> ´¦ÀíÎļþʱÓõ½
< % @ Import Namespace="System.Web.Util" %> ·¢Óʼþʱ´ó¼Ò»áÓõ½
< % @ Import Namespace="System.Text" %> Îı¾±àÂëʱÓõ½
5.Connections(SQLConection »òÕß ADOConnection)µÄ³£ÓÃÊôÐԺͷ½·¨:
| ConnectionString È¡µÃ»òÉèÖÃÁ¬½áÊý¾Ý¿âµÄÓï¾ä
| ConnectionTimeout È¡µÃ»òÉèÖÃÁ¬½áÊý¾Ý¿âµÄ×ʱ¼ä£¬Ò²ÊǾͳ¬Ê±Ê±¼ä
| DataBase È¡µÃ»òÉèÖÃÔÚÊý¾Ý¿â·þÎñÆ÷ÉÏÒª´ò¿ªµÄÊý¾Ý¿âÃû
| DataSource È
Ïà¹ØÎĵµ£º
ÿ´Î½«ÍøÒ³·¢Ë͵½·þÎñÆ÷ʱ£¬¶¼»á´´½¨ÍøÒ³ÀàµÄÒ»¸öÐÂʵÀý¡£ÔÚ´«Í³µÄ Web ±à³ÌÖУ¬Õâͨ³£Òâζ×ÅÔÚÿһ´ÎÍù·µÐгÌÖУ¬Óë¸ÃÒ³¼°¸ÃÒ³ÉϵĿؼþÏà¹ØÁªµÄËùÓÐÐÅÏ¢¶¼»á¶ªÊ§¡£ÀýÈ磬Èç¹ûÓû§½«ÐÅÏ¢ÊäÈëµ½Îı¾¿ò£¬¸ÃÐÅÏ¢½«ÔÚ´Óä¯ÀÀÆ÷»ò¿Í»§¶ËÉ豸µ½·þÎñÆ÷µÄÍù·µÐгÌÖжªÊ§¡£
ΪÁ˽â¾ö´«Í³µÄ Web ±à³Ìµ ......
ASP.NET ÅäÖÃÎļþ¹¦ÄÜÓë ASP.NET ³ÉÔ±×ʸñ¡¢ASP.NET ½ÇÉ«¹ÜÀíÒÔ¼°ÆäËû ASP.NET ¹¦ÄÜʹÓÃͬһ»ùÓÚÌṩ³ÌÐòµÄ½á¹¹¡£ASP.NET ÅäÖÃÎļþ¹¦ÄÜÊÇÒ»¸ö·Ö²ãϵͳ£¬ÆäÖÐÅäÖÃÎļþ¹¦ÄܵŦÄÜ£¨ÌṩÀàÐÍ»¯ÊôÐÔÖµ²¢¹ÜÀíÓû§±êʶ£©Óë»ù´¡Êý¾Ý´æ´¢Çø·ÖÀë¡£ÅäÖÃÎļþ¹¦ÄÜÒÀÀµÓÚÅäÖÃÎļþÌṩ³ÌÐò£¨Êý¾ÝÌṩ³ÌÐò£©À´Ö´Ðд洢ºÍ¼ìË÷ÅäÖÃÎļþÊôÐÔ ......
ÔÚ´´½¨ ASP.NET Íøҳʱ£¬Äú¿ÉÒÔʹÓÃÒÔÏÂÀàÐ͵Ŀؼþ£º
· HTML ·þÎñÆ÷¿Ø¼þ ¶Ô·þÎñÆ÷¹«¿ªµÄ HTML ÔªËØ£¬¿É¶ÔÆä½øÐбà³Ì¡£HTML ·þÎñÆ÷¿Ø¼þ¹«¿ªÒ»¸ö¶ÔÏóÄ£ÐÍ£¬¸ÃÄ£ÐÍÊ®·Ö½ôÃܵØÓ³Éäµ½ÏàÓ¦¿Ø¼þËù³ÊÏÖµÄ HTML ÔªËØ¡£
·Web ·þÎñÆ÷¿Ø¼þ ÕâЩ¿Ø¼þ±È HTML ·þÎñÆ÷¿Ø¼þ¾ßÓиü¶àÄÚÖù¦ÄÜ¡£We ......
1. Êý¾Ý¿â·ÃÎÊÐÔÄÜÓÅ»¯
Êý¾Ý¿âµÄÁ¬½ÓºÍ¹Ø±Õ
·ÃÎÊÊý¾Ý¿â×ÊÔ´ÐèÒª´´½¨Á¬½Ó¡¢´ò¿ªÁ¬½ÓºÍ¹Ø±ÕÁ¬½Ó¼¸¸ö²Ù×÷¡£ÕâЩ¹ý³ÌÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»»ÐÅÏ¢ÒÔͨ¹ýÉí·ÝÑéÖ¤£¬±È½ÏºÄ·Ñ·þÎñÆ÷×ÊÔ´¡£ASP.NETÖÐÌṩÁËÁ¬½Ó³Ø(Connection Pool)¸ÄÉÆ´ò¿ªºÍ¹Ø±ÕÊý¾Ý¿â¶ÔÐÔÄܵÄÓ°Ï졣ϵͳ½«Óû§µÄÊý¾Ý¿âÁ¬½Ó·ÅÔÚÁ¬½Ó³ØÖУ¬ÐèҪʱȡ³ö£¬¹Ø±ÕʱÊÕ»ØÁ¬½ ......
using System;
using System.Collections.Specialized;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebC ......