Difference between special tags asp.net

前端 未结 3 1861
自闭症患者
自闭症患者 2021-01-15 12:47

I\'m developing a front-end part of an application right now, and a question came to my mind.

What is the difference between asp.net special tags:

&l         


        
相关标签:
3条回答
  • 2021-01-15 13:28
    • <%= prints the raw value of the expression within.
      This syntax can cause XSS vulnerabilities and should not be used.

    • <%: prints and HTML-escapes the value of the expression within.

    • <%# is like <%=, but is used for data-binding

    • <% executes a block of code and ignores and return values

    • <%@ is used for directives like Page or Imports.

    0 讨论(0)
  • 2021-01-15 13:29

    Check the below site Once..You will get an idea

    http://naspinski.net/post/inline-aspnet-tags-sorting-them-all-out-(3c25242c-3c253d2c-3c252c-3c252c-etc).aspx

    These are some useful special tags

    • <% %> An embedded code block is server code that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class. http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx

    • <%= %> most useful for displaying single pieces of information. http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx

    • <%# %> Data Binding Expression Syntax. http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx

    • <%$ %> ASP.NET Expression. http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx

    • <%@ %> Directive Syntax. http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx

    • <%-- --%> Server-Side Comments. http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx

    • <%: %> Like <%= %> But HtmlEncodes the output (new with Asp.Net 4). http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx

    0 讨论(0)
  • 2021-01-15 13:32
    • <%= %> Code Render Block - For evaluate inline expressions
    • <%@ %> Directive Syntax - Usualy for linking the codebehind and a asp.net page.
    • <%# %> Data binding

    You can find more information at: http://msdn.microsoft.com/en-us/library/fy30at8h(v=vs.85).aspx

    0 讨论(0)
提交回复
热议问题