Saturday, September 28, 2024

ASP.NET Webforms Notables

 

The ASP.NET Web Application template uses the Bundle.config file at the root of the project to store the path of the Bootstrap CSS files.

The tilde (~)

The tilde (~) character is used to specify that the href path begins at the root of the project.




Data-binding expression syntax

Code contained inside the container <%#: %> marks a data-binding expression. By adding the (:) to the end of the <%# prefix, the result of the data-binding expression is HTML-encoded. When the result is HTML-encoded, your application is better protected against cross-site script injection (XSS) and HTML injection attacks.

1
2
3
4
5
6
7
<ItemTemplate>
    <b>
        <a href="/ProductList.aspx?id=<%#: Item.CategoryID %>">
            <%#: Item.CategoryName %>
        </a>
    </b>
</ItemTemplate>


Code Blocks

In ASP.NET, an HTML template is a plain piece of markup intertwined with <% . . . %> code blocks.  Code blocks basically contain data binding expressions that are evaluated at compile time and translated into executable statements. At runtime, then, statements produce literals integrated with markup.

No comments: