ASP.NET code expression, data binding, and other declarative expressions

What are the differences in these tags?

<% <% # <% = <% $

More importantly, how do I show a page property using declarative syntax in an ASP.NET control? I am trying to do this in an ASP.NET control. The task is to set the label text, but I do not want to do this programmatically in case I want to change the output control. I get an error when server-side controls cannot contain this syntax. I'm not sure that I need data binding control for what I want to do, but this is another option.

Partial answer.

Update Is there a new tag that I saw in ASP.NET 4.5? site

<%:

+5
source share
2 answers

Partial answer

quoted by Mike Banawige

<%%> The built-in code block is the server code that is executed during the page render phase. The code in the block can perform programming of operators and call functions in the current page class. http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx

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

<% #%> The syntax of the data binding expression. http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx

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

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

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

Update:

,

<asp:Label ID="MyLabel" runat="server" Text='<%# MyProperty%>'></asp:Label>

eval, <%, . . , , .

, - .

:

<% = , , .

<% # , PageDatabind.

, <% = <% #, , . .

<%: ,

ASP.NET 4 (<%: % > ), , , <% =% > blocks, HTML .

http://weblogs.asp.net/scottgu/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2

+9

, . , SkinPath, App_Themes . :

<img src='<%= SkinPath %>/Images/myImage.png' />

:

<asp:Image ID='image' runat='server' ImageUrl='<%= SkinPath %>/Images/myImage.png' />

src <img>.

0

All Articles