开发者

Meaning of the various symbols in .aspx page of asp.net

I have come across different symbols in .aspx page of asp.net

<%#eval(expr) %> 
<%#bind(expr) %>
<% %>  - for specifying the c# code in aspx page
<%$ %> - for specifying the SQL connection string in <asp:SqlDataSource>

Is there any underlying logic behind these symbols or is it开发者_JS百科 just syntax which we have to remember blindly? What does <% %> mean in general?


It is just syntax.

<% %> is simply short for <script runat="server"> </script> aka code render blocks.

<%# %> are binding expressions (plus the above).

<%= %> is the above + a Response.Write().

<%: %> is the above + a Response.Write() wrapped in Html.Encode (new in .NET 4.0).

<%$ %> is an ASP.NET expression, used to bind configuration or resource file data during runtime.


Remember it. It's more poorly documented ASP.net syntax to help maintain inconsistencies and fallout from ASP 'classic' groans. Also don't forget

<%=variablename %>  
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜