ʹÓÃASP.NETÖеÄÓû§¿Ø¼þ
Óû§¿Ø¼þÊÇASP.NETÖкÜÖØÒªµÄÒ»²¿·Ö£¬Ê¹ÓÃËü¿ÉÒÔÌá¸ß³ÌÐò´úÂëµÄÖØÓÃÐÔ£¬¼´Ò»¸öÓû§¿Ø¼þÔÚÍøÒ³¡¢Óû§¿Ø¼þ»ò¿Ø¼þµÄÄÚ²¿¶¼¿ÉÒÔÔÙ´ÎʹÓᣱ¾ÊµÀý½éÉÜÓû§µÇ¼µÄÓû§¿Ø¼þÒ²¿ÉÒÔÔÚÍøÕ¾µÄÈκεط½ÔÙ´ÎʹÓá£
¼¼ÊõÒªµã
±¾ÊµÀý½éÉÜÈçºÎÔÚASP.NETÖд´½¨Óû§¿Ø¼þ¡¢ÈçºÎʹÓÃÓû§¿Ø¼þ£¬ÒÔ¼°ÈçºÎÔÚÓû§¿Ø¼þÖж¨Ò幫¿ªÊôÐÔµÄʵÏÖ·½·¨¡£
¸úÎÒ×ö
1£®´´½¨ÐÂASP.NETÓ¦ÓóÌÐò
ÔÚVisual Studio .NET 2003¼¯³É¿ª·¢»·¾³Öд´½¨ÐµÄASP.NET WebÓ¦ÓóÌÐò£¬ÃüÃûΪExample_12_4¡£
2£®´´½¨Óû§µÇ¼Óû§¿Ø¼þMyUserControl.ascx
ÔÚÓ¦ÓóÌÐòExample_12_4ÖÐÌí¼Ó1¸öÓû§¿Ø¼þ£¬ËüµÄÃû³ÆΪMyUserControl.ascx£¬²¢ÔÚÓû§¿Ø¼þÉÏÌí¼Ó2¸öTextBox¿Ø¼þºÍ2¸öButton¿Ø¼þ£¬ËüÃǵÄÃû³Æ·Ö±ðΪtUserName¡¢tPassword¡¢UserLoginBtnºÍCancelBtn¡£
¿Ø¼þtUserNameºÍtPassword·Ö±ðÓÃÀ´ÊäÈëÓû§Ãû³ÆºÍÓû§ÃÜÂ룻¿Ø¼þUserLoginBtnºÍCancelBtnʵÏÖÓû§µÇ¼¹¦ÄܺÍÈ¡ÏûµÇ¼¹¦ÄÜ¡£Óû§µÇ¼Óû§¿Ø¼þMyUserControl.ascxµÄÉè¼Æ½çÃæÈçͼ12-9Ëùʾ¡£
ͼ12-9 Óû§¿Ø¼þMyUserControl.ascxµÄÉè¼Æ½çÃæ
Óû§¿Ø¼þMyUserControl.ascxµÄHTMLÉè¼Æ´úÂëÈçÏ£º
<%@ Control Language="c#" AutoEventWireup="false"
Codebehind="MyUserControl.ascx.cs" Inherits="
Example_12_4.MyUserControl"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
<td colspan="2">Óû§µÇ¼Óû§¿Ø¼þ£º</td>
<td width="150" align="right">Óû§Ãû³Æ£º</td>
<asp:TextBox id="tUserName" runat="server" width="200"></asp:TextBox>
<td width="150" align="right">Óû§ÃÜÂ룺</td>
<asp:TextBox id="tPassword" runat="server" width="200"
TextMode="Password"></asp:TextBox>
<asp:Button id="UserLoginBtn" runat="server" Text="È· ¶¨"></asp:Button>
<asp:Button id="CancelBtn" runat="server" Text="È¡ Ïû"></asp:Button>
3£®ÉèÖÃÓû§µÇ¼Óû§¿Ø¼þMyUserControl.ascxµÄʼþºÍº¯Êý
ÔÚÓ¦ÓóÌÐòExample_12_4ÖÐÌí¼ÓÓû§¿Ø¼þµÄÊôÐÔUserNameºÍPassword£¬·Ö±ð±íʾÓû§¿Ø¼þÖпؼþUserNameºÍ¿Ø¼þPasswordµÄÊôÐÔTextµÄÖµ¡£ÊôÐÔUserNameºÍÊôÐÔPasswordµÄ³ÌÐò´úÂëÈçÏ£º
//Ìí¼ÓÊôÐÔUserName
public String UserName
{
get{return(tUserName.Text);} &n
Ïà¹ØÎĵµ£º
ÔÚWeb±à³Ì¹ý³ÌÖУ¬´æÔÚןܶలȫÒþ»¼¡£±ÈÈçÔÚÒÔÇ°µÄASP°æ±¾ÖУ¬CookieΪ·ÃÎÊÕߺͱà³ÌÕ߶¼ÌṩÁË·½±ã£¬²¢Ã»ÓÐÌṩ¼ÓÃܵŦÄÜ¡£´ò¿ªIEä¯ÀÀÆ÷£¬Ñ¡Ôñ“¹¤¾ß”²Ëµ¥ÀïµÄ“InternetÑ¡Ï¬È»ºóÔÚµ¯³öµÄ¶Ô»°¿òÀïµ¥»÷“ÉèÖÔ°´Å¥£¬Ñ¡Ôñ“²é¿´Îļþ”°´Å¥£¬ÔÚµ¯³öµÄ´°¿ÚÖУ¬¾Í»áÏÔʾӲÅÌÀï ......
ѧϰ×Ô¶¨Òå¿Ø¼þµÄ¿ª·¢²»½ö¿ÉÒÔʹÄ㿪·¢³ö¸üÁé»îµÄϵͳ¸üÖØÒªµÄÊÇËü¿ÉÒÔʹÄã¼ÓÉî¶ÔÒÑÓзþÎñÆ÷¿Ø¼þµÄÀí½â£¬µÃÒÔ¸üÁé»îµÄÓ¦Óá£
½ÏÖ®ÓÚasp£¬asp.netÌṩÁ˸üÇ¿´óµÄ¹¦ÄÜ£¬ÎұȽÏϲ»¶ËüµÄ´úÂë·ÖÀë¼¼ÊõºÍ¶ÔÖîÈçC#¡¢VB.NetµÈÇ¿ÀàÐÍÓïÑÔµÄʹÓã¬ÕâÊÇ´Ó¿ª·¢ÕߵĽǶÈÀ´¿´µÄ£¬´ÓÓû§µÄ½Ç¶ÈÀ´¿´£¬»á¾õµÃËüËٶȸü¿ì£¬ÔËÐиüÎȶ¨£¬ ......
ListView »ù´¡
ListView ÊÇÄ£°åÇý¶¯µÄ¿Ø¼þ£¬ÕâÒâζ×ÅËüĬÈÏÇé¿öϲ»»á³ÊÏÖÈκÎÊý¾Ý——Äú±ØÐëÒÔÄ£°åµÄÐÎʽÍêÈ«Ö¸¶¨Ï£ÍûËü³ÊÏÖµÄ HTML¡£Óë´ó¶àÊýÄ£°å¿Ø¼þÀàËÆ£¬ItemTemplate ½«³ÉΪÄú¹¤×÷µÄÖص㣬ÄúÐèÒª½«°ó¶¨Êý¾Ý¼¯ÖÐÿһÐ⻶ÏÖظ´µÄ HTML ÄÚÈÝ·ÅÔÚ ItemTemplate Àï¡£
ListView ÖеÄй¦ÄÜ£¬Ò²ÊÇËüÓëÆäËü¿Ø¼þµ ......
ÔÚASP.NETÖÐ,ÎÒÃÇ¿ÉÒÔÓÃÏÂÃæµÄ·½·¨ÊµÏÖ´ÓÊý¾Ý¿âÖжÁȡͼƬ²¢ÏÔʾÔÚÒ³ÃæÉÏ,·½·¨ÈçÏÂ:
SqlConnection conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
String sql="SELECT image from append where id='" + strID + "'";
&n ......
1.¹Ø±Õ²»±ØÒªµÄSession
<%@ Page EnableSessionState="flase"%>
2.¹Ø±Õ²»±ØÒªµÄViewState
<asp:DataGrid EnableViewState="false" runat="server">
Èç¹ûÒ³Ã漶
<%@ Page EnableViewState="false"%>
3.²»ÒªÊ¹ÓÃException¿ØÖƳÌÐòÁ÷³Ì
ExceptionÊǺܺÄ×ÊÔ´µÄ
4.½ûÓÃVBºÍJScript¶¯Ì¬Êý ......