Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ASP.NET Literal¿Ø¼þÓ÷¨

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 ¿Ø¼þµÄÎı¾ºÍ±àÂë¡£¸ÃÒ³°üº¬Ò»×鵥ѡ°´Å¥£¬ÔÊÐíÓû§ÔÚ±àÂëÎı¾ºÍ´«µÝÎı¾Ö®¼äÑ¡Ôñ¡£
×¢Òâ
Èç¹ûÄúÕý½« Text ÊôÐÔÉèÖÃΪÀ´×Ô²»ÊÜÐÅÈÎÔ´µÄÎı¾£¬ÔòÓ¦½«¿Ø¼þµÄ Mode ÊôÐÔÉèÖÃΪ Encode£¬ÕâÑù±ê¼Ç²Å²»»áÐγɿÉÖ´Ðбê¼Ç¡£
<%@ Page Language="C#" %>
<script runat="server">
    protected void Page_Load(object sender ,EventArgs e)
    {
        // Literal1.Text = "This <b>text </b> is inserted dynamically.";
        Literal1.Text = " <script language='javascript'>alert('ÄãÖвÊÁË£¡'); <"+"/script>";
        if(radioEncode.Checked == true)
        {
         
            Literal1.Mode = LiteralMode.Encode;
        }
        if(radioPassthrough.Checked == true)
        {
            Literal1.Mode = LiteralMode.PassThrough;
       


Ïà¹ØÎĵµ£º

asp.net¿ØÖÆÍøÕ¾·Ö±æÂÊ

¿ØÖÆÍøÕ¾·Ö±æÂÊ ÎÒÃÇ¿ÉÒÔ Óà frameset
ËäÈ» asp.net²»Ö§³ÖÕâ¸öÊôÐÔ µ«Êǹ¦ÄÜÊÇ¿ÉÒÔʵÏÖµÄ
Èç £º
<frameset name="main" rows="105,*" frameborder="no" border="0" framespacing="0">
  <frame src="xx.aspx" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" /> ......

ASP.NET"ÕýÔÚÖÐÖ¹Ïß³Ì"´íÎóÔ­Òò

PRB£ºÔÚʹÓà Response.End¡¢Response.Redirect »ò Server.Transfer ʱ³öÏÖ ThreadAbortException
Ö¢×´
Èç¹ûʹÓà Response.End¡¢Response.Redirect »ò Server.Transfer ·½·¨£¬½«³öÏÖ ThreadAbortException Òì³£¡£Äú¿ÉÒÔʹÓà try-catch Óï¾ä²¶»ñ´ËÒì³£¡£
Ô­Òò
Response.End ·½·¨ÖÕÖ¹Ò³µÄÖ´ÐУ¬²¢½«´ËÖ´ÐÐÇл»µ½Ó¦ÓóÌÐò ......

Asp.NetÖÐOnClientClickÓëOnClick (ת)

ÔÚweb¿ª·¢ÖÐ,¾­³£ÒªÓõ½¿Ø¼þµÄOnClientClickÓëOnClickʼþ.
Èç¹ûʹÓò»µ±,¾­³£»áÓöµ½Ò»Ð©ÒâÁÏÖ®ÍâµÄÊÂÇé·¢Éú,ÈÃÈËÃþ²»×ÅÍ·ÄÔ.ÏÂÃæ¾Í½«ÎÒµÄһЩСС×ܽáµÀÀ´:
Ê×ÏÈÎÒÃÇÒªÁ˽âÕâÁ½¸öʼþ:
OnClientClickÊǿͻ§¶Ëʼþ·½·¨.Ò»°ã²ÉÓÃJavaScriptÀ´½øÐд¦Àí.Ò²¾ÍÊÇÖ±½ÓÔÚIE¶ËÔËÐÐ.Ò»µã»÷¾ÍÔËÐÐ.
OnClickʼþÊÇ·þÎñÆ÷¶Ëʼþ´¦Àí ......

¿ØÖÆAsp.netµÄButton¿Ø¼þµÄÌá½»¶¯×÷

asp.net¿ª·¢ÖУ¬Í¨³£ÐèÒª×öһЩ¿Í»§¶ËÑéÖ¤¡£µ±ÎÒÃÇĬÈÏÔÚÒ»¸öÒ³ÃæÖмӸöbutton¿Ø¼þʱ£¬Õâ¸öButton±»asp.net Êä³öΪһ¸öSubmit°´Å¥¡£ asp:Button ID=Button1 runat=server Text=Button on click=Button1_Click /
ÔÚ_doPostBack·½·¨ÄÚ£¬Í¨¹ýtheForm.submit()À´Ê¹Êý¾ÝÌá½»µ½·þÎñÆ÷¡£
ÕâÑùºÜÈÝÒ׿´³ö£¬Èç ¹ûÎÒÃÇÏëÒªÔÚÊý¾ÝÌá½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ