ASP.NET Literal¿Ø¼þÓ÷¨_»ªÎª½ðɽÍø
ÔÚÄúÒªÒÔ±à³Ì·½Ê½ÉèÖÃÎı¾¶ø²»Ìí¼Ó¶îÍâµÄ HTML ±ê¼Çʱ£¬¿ÉÒÔÏòÒ³ÃæÌí¼Ó Literal Web ·þÎñÆ÷¿Ø¼þ¡£ÔÚÒªÏòÒ³Ã涯̬Ìí¼ÓÎı¾¶ø²»Ìí¼ÓÈκβ»ÊôÓڸö¯Ì¬Îı¾µÄÔªËØʱ£¬Literal ¿Ø¼þ·Ç³£ÓÐÓá£ÀýÈ磬Äú¿ÉÒÔʹÓà Literal ¿Ø¼þÀ´ÏÔʾ´ÓÎļþ»òÁ÷ÖжÁÈ¡µÄ HTML¡£
×¢Òâ
Èç¹ûÒªÏÔʾ¾²Ì¬Îı¾£¬Ôò¿ÉÒÔʹÓà HTML ³ÊÏÖËü£»²»ÐèÒª Literal ¿Ø¼þ¡£Ö»ÓÐÔÚÐèÒªÒÔ±à³Ì·½Ê½³ÊÏÖÎı¾Ê±²ÅʹÓà Literal ¿Ø¼þ¡£
Ïò Web ´°ÌåÒ³Ìí¼Ó Literal ¿Ø¼þ
½« <asp:Literal> ÔªËؼüÈëÒ³Ãæ¡£
ÏÂÃæµÄʾÀýÏÔʾһ¸ö¼òµ¥Ò³£¬¸ÃÒ³ÔÚÔËÐÐʱÏÔʾ±êÌâÐÂÎÅ¡£¸ÃÒ³µÄÖ÷Ì壨°üÀ¨ Literal ¿Ø¼þ£©ÀàËÆÓÚÏÂÃæµÄ´úÂ룺
<body>
<form runat="server">
<h1> <asp:Literal runat=server /> </h1>
</form>
</body>
»òÕߣ¬½« Mode ÊôÐÔÉèÖÃΪ Transform¡¢PassThrough »ò Encode¡£Mode ÊôÐÔÖ¸¶¨¿Ø¼þÈçºÎ´¦ÀíÄúÌí¼Óµ½¸Ã¿Ø¼þÖеıê¼Ç¡£
½«´úÂëÌí¼Óµ½Ò³ÃæÉÏÒÔÔÚÔËÐÐʱÉèÖÿؼþµÄ Text ÊôÐÔ¡£
ÏÂÃæµÄʾÀýÑÝʾÈçºÎÒÔ±à³Ì·½Ê½ÉèÖà Literal ¿Ø¼þµÄÎı¾ºÍ±àÂë¡£¸ÃÒ³°üº¬Ò»×鵥ѡ°´Å¥£¬ÔÊÐíÓû ......
תÔØ×Ô¡¾ÃÏ×ÓEÕ¡¿£ºhttp://blog.csdn.net/net_lover/archive/2007/08/27/1760521.aspx
¾³£ÓÐÈËÓöµ½ASP.NET 2.0£¨ASP.NET 1.xÖпÉÄÜÊÇÓÐЧµÄ£©ÖÐCSSʧЧµÄÎÊÌ⣬ÏÖ½«Ö÷ÒªÔÒòºÍ½â¾ö·½·¨ÂÞÁÐÈçÏ£º
1.CSSÎļþ·¾¶²»ÕýÈ·
Õâ¸öÎÊÌâÊôÓÚWeb¿ª·¢ÖеĻù´¡ÎÊÌ⣬һ°ã²ÉÓÃÏà¶Ô·¾¶»á³öÏÖÕâÑùµÄÎÊÌ⣬»òÕßÑùʽÎļþдÔÚÁËĸ°æÒ³ÀïÃ棬ÔÚÄÚÈÝÒ³Óëĸ°æÒ³²»ÔÚͬһ¼¶Ä¿Â¼ÏÂʱ»á³öÏÖÕâÑùµÄÎÊÌâ¡£´ËʱÄãÒªÇå³þWebÖÐÏà¶Ô·¾¶µÄ¹æÔò£¬Èç¹ûÄã²»Çå³þ£¬¿ÉÒÔ²ÉÓþø¶Ô·¾¶µÄд·¨ÊÔÊÔ¾ÍÖªµÀÊDz»ÊÇ·¾¶µÄÎÊÌâÁË¡£
2.CSS¹æÔòд·¨´íÎó
Õâ¸öÎÊÌâËÒ²°ï²»Ä㣬ֻÄÜ×Ô¼ºÑ§Ï°CSSµÄÏà¹Ø֪ʶÁË¡£
3.Îļþ±àÂëÎÊÌâ
ÓÐʱºò£¬CSSÑùʽ·ÅÔÚaspxÎļþÀïÓÐЧ£¬¶ø·ÅÔÚ¶ÀÁ¢µÄÎļþÖÐÎÞЧ£¬ÕâÑùµÄÎÊÌâÈç¹û²»ÊÇ·¾¶ÎÊÌ⣬Ôò¾ÍÊDZàÂëÎÊÌâÔì³ÉµÄ£¬¿ÉÒÔ½«CSSÎļþÓüÇʱ¾´ò¿ª£¬ÔÙÁí´æΪANSI¸ñʽ»òÕßUTF-8¸ñʽ¼´¿É¡£
4.ȨÏÞÎÊÌâ
ÕâÖÖÇé¿ö³£¼ûµÄÏÖÏóÊǵǼ֮ǰÑùʽÎÞЧ£¬µÇ¼֮ºó²ÅÓÐЧ£¬ÕâÊǵäÐ͵ÄȨÏÞÎÊÌâÔì³ÉµÄ¡£ÓÉÓÚweb.configÅäÖÃÁËËùÓÐÎļþ²»ÔÊÐíÄäÃû·ÃÎÊ£¬²Å»á³öÏÖÕâÑùµÄÎÊÌ⣬½â¾ö·½·¨¾ÍÊǽ«<location>±ê¼Ç½«ÑùʽÎļþÅäÖÃΪÔÊ ......
¶¼ÖªµÀÔÚ¿Í»§諯ʹÓõ¯³ö¿òµÄÊDz»ÄÜÓÃMesssageBoxÀ´ÊµÏÖµÄ.
Ò»°ã¶¼Ê¹ÓÃÒÔϼ¸ÖÖ·½·¨.
1) Button.Attributes.Add("onclick","javascript:return confirm('È·¶¨?');");
ÕâÖÖ·½·¨..ÏÖÔÚʹÓÃ×îµÄ¶à..
ÔÚwww.csdn.netÀïÓÐÒ»ÎÄÕ¾ͺܺÃ.
http://www.csdn.net/Develop/Read_Article.asp?Id=20892
´ó¼Ò¿ÉÒÔ¿´Ò»ÏÂ..»áÓкܶàÊÕ»ñ.
2)ÁíÒ»¸ö·½·¨..ÎÒ²»ÖªµÀÆäËüÈËÓÐûÓÐÕâôÓÃ.²»¹ýÎÒÊÇÕâôÓõÄ..ºÜ͵ÀÁµÄ°ì·¨¾©ÊÇ
< div id=div1 onclick="javascript:return confirm('È·¶¨?');"><asp: button id="Button1" runat="server" Text="Button"></asp:button></div>
Õâ¸öÒ»ÑùÄÜʵÏÖ..¶øÇÒ²»ÓÃÔö¼Ó·þÎñÆ÷µÄ¶¯×÷...²»¹ýÓÐûÓÐÆäËüºó¹û..¾Í²»..ÖªµÀÁË..
ÔÚDataGridÖÐÒ»ÑùÔÚButtonÁÐÖÐʹÓÃÊôÐÔ±à¼Æ÷ÔÚÎı¾(t)ÖÐдÈë
<div id=div1 onclick="javasciprt:return confrim(È·¶¨?')">ɾ³ý</div>¾ÍÄÜÔÚDataGridÖÐʵÏÖɾ³ýÈ·ÈϵŦÄÜ..µ±È»Èç¹ûÿÐÐɾ³ý²»Ò»ÑùÄã¾ÍµÃÓÃÆäËü·½·¨ÁË.
http://www.csdn.net/Develop/Read_Article.asp?Id=20892
ÖÐÒ»ÑùÓнéÉÜ.
3)¿ÉÄÜÓÐʱºò´ó¼Ò»áÕâÑùµÄÓô¦..¾ÍÊÇÄãµã»÷µ¼ÈëÊý¾ÝµÄButto ......
Ò»¡¢Ä¿Ç°ÔÚASP.NETÖÐÒ³Ãæ´«Öµ¹²ÓÐÕâô¼¸ÖÖ·½Ê½£º
1¡¢±íµ¥Ìá½»£¬
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
form1.submit();
....
´ËÖÖ·½ÔÚASP¡£NETÖÐÎÞЧ£¬ÒòΪASP¡£NETµÄ±íµ¥×ÜÊÇÌá½»µ½×ÔÉíÒ³Ã棬Èç¹ûÒªÌá½»µ½±ðÒ»Ò³Ã棬ÐèÒªÌØÊâ´¦Àí¡£
2¡¢<A href="target.aspx?param1=1111¶m2=2222">Á´½ÓµØÖ·´«ËÍ</A>
½ÓÊÕÒ³Ã棺 string str = Request["param1"]
3¡¢Session¹²Ïí
·¢ËÍÒ³Ã棺Session("param1") = "1111";
°´ÊÕÒ³Ãæ string str = Session("param1").ToString();
4¡¢Application¹²Ïí
·¢ËÍÒ³Ã棺 Application("param1") = "1111";
°´ÊÕÒ³Ã棺 string str = Application("param1").ToString();
´ËÖÖ·½·¨²»³£Ê¹Óã¬ÒòΪApplicationÔÚÒ»¸öÓ¦ÓóÌÐòÓò·¶Î§¹²Ïí£¬ËùÓÐÓû§¿ÉÒԸı估ÉèÖÃÆäÖµ£¬¹ÊÖ»Ó¦ÓüÆÊýÆ÷µÈÐèҪȫ¾Ö±äÁ¿µÄµØ·½¡£
5¡¢Cookie
6¡¢Respon ......
<a>±êÇ©
1. <a href=”test.aspx”></a>
2. ÕâÊÇ×î³£¼ûµÄÒ»ÖÖתÏò·½·¨;
HyperLink¿Ø¼þ
1. Asp.net ·þÎñÆ÷¶Ë¿Ø¼þ ÊôÐÔNavigateUrlÖ¸¶¨ÒªÌøתµ½µÄUrlµØÖ·
2. NavigateUrlÊÇ¿ÉÒÔÔÚ·þÎñÆ÷¶ËʹÓôúÂëÐ޸ģ¬Õâ¸öÇø±ðÓÚ<a>
3. ÓÉÓÚHyperLink±¾ÉíûÓÐʼþËùÒÔÒªÔÚ·þÎñÆ÷¶ËÆäËüʼþÖÐÉèÖÃNavigateUrl
4. ´úÂëʾÀý
<Asp:HyperLink id=”hyperlink” runat=”server” NavigatoeUrl=”test.aspx”>ok</Asp:HyperLink>
Response.Redirect()·½·¨
1. ¹ý³Ì£º·¢ËÍÒ»¸öHttpÏìÓ¦µ½¿Í»§¶Ë£¬Í¨Öª¿Í»§¶ËÌøתµ½Ò»¸öеÄÒ³Ã棬Ȼºó¿Í»§¶ËÔÙ·¢ËÍÌøתÇëÇóµ½·þÎñÆ÷¶Ë¡£
2. Ò³ÃæÌøת֮ºóÄÚ²¿¿Ø¼þ±£ ......
1 response.redirect Õâ¸öÌøתҳÃæµÄ·½·¨ÌøתµÄËٶȲ»¿ì£¬ÒòΪËüÒª×ß2¸öÀ´»Ø£¨2´Îpostback£©£¬µ«Ëû¿ÉÒÔÌøתµ½ÈκÎÒ³Ã棬ûÓÐÕ¾µãÒ³ÃæÏÞÖÆ£¨¼´¿ÉÒÔÓÉÑÅ»¢Ìøµ½ÐÂÀË£©£¬Í¬Ê±²»ÄÜÌø¹ýµÇ¼±£»¤¡£µ«ËÙ¶ÈÂýÊÇÆä×î´óȱÏÝ£¡redirectÌøת»úÖÆ£ºÊ×ÏÈÊÇ·¢ËÍÒ»¸ö httpÇëÇ󵽿ͻ§¶Ë£¬Í¨ÖªÐèÒªÌøתµ½ÐÂÒ³Ã棬Ȼºó¿Í»§¶ËÔÚ·¢ËÍÌøתÇëÇóµ½·þÎñÆ÷¶Ë¡£ÐèҪעÒâµÄÊÇÌøתºóÄÚ²¿¿Õ¼ä±£´æµÄËùÓÐÊý¾ÝÐÅÏ¢½«»á¶ªÊ§£¬ËùÒÔÐèÒªÓõ½session¡£
2 server.transfer Ëٶȿ죬ֻÐèÒªÒ»´Îpostback ,µ«ÊÇ¡£¡£¡£¡£Ëû±ØÐëÊÇÔÚͬһ¸öÕ¾µãÏ£¬ÒòΪËüÊÇserverµÄÒ»¸ö·½·¨¡£ÁíÍ⣬ËûÄÜÌø¹ýµÇ¼±£»¤¡£Äã¿ÉÒÔд¸öС³ÌÐòÊÔÊÔ£ºÉè¼ÆÒ»¸öÓÉÒ³ÃæÒ»µ½Ò³Ãæ¶þµÄÌøת£¬µ«Òª½øÈëµ½Ò³Ãæ¶þÐèÒªµÇ¼£¬formÈÏÖ¤£¬µ«Èç¹ûÌøתÓï¾äʹÓÃtransferµÄ»°£¬ÄǾͲ»»áµ¯³öµÇ¼ҳÃæÁË¡£Õâ¸ö·½·¨µÄÖض¨ÏòÇëÇóÊÇ·¢ÉúÔÚ·þÎñÆ÷¶Ë£¬ËùÒÔä¯ÀÀÆ÷µÄurlµØÖ·ÈÔÈ»±£ÁôµÄÊÇÔÒ³ÃæµÄµØÖ·£¡
3 sever.execute Õâ¸ö·½·¨Ö÷ÒªÊÇÓÃÔÚÒ³ÃæÉè¼ÆÉÏÃ棬¶øÇÒËû±ØÐëÊÇÌøתͬһվµãϵÄÒ³Ãæ¡£Õâ¸ö·½·¨ÊÇÐèÒª½«Ò»¸öÒ³ÃæµÄÊä³ö½á¹û²åÈëµ½ÁíÒ»¸öaspxÒ³ÃæµÄʱºòʹÓ㬴󲿷ÖÊÇÔÚ±í¸ñÖУ¬½«Ä³Ò»¸öÒ³ÃæÀàËÆÓÚǶÌ׵ķ½Ê½´æÔÚÓÚÁíÒ»Ò³Ãæ¡£
×ܽ᣺
µ±ÐèÒª°ÑÓû§Ìøתµ½Áíһ̨·þÎñÆ÷Éϵ ......