Inline tags are useful in-order to write inline codes in the ASP .Net view page (aspx/ascx) pages .
Now in MVC view pages are using inline tags for inline coding, because in MVC we do not have any code behind for the view page.
Please find out some below mentioned frequently inline tags .
1. Normal Inline Tag: <% .... %>
Exmaple :
<% if (User.IsInRole("admin")) { %>
You can see this
<% } else { %>
You are no admin !
<%} %>
2. Single Pieces of Info: <%= ... %>
Used for small chunks of information, usually from objects and single pieces of information like a single string or int variable:
Example :
The Date is now <%= DateTime.Now.ToShortDateString() %>
The value of string1 is <%= string1 %>
*Note: <%= is the equivalent of Response.Write()
3. Binding Expression Tag : <%# .. %>
This tag is used to Binding Expressions, such as Eval and Bind, most often found in data controls
like GridView, Repeater, etc.:
Exmaple :
<asp:Repeater ID="rptMeetings" DataSourceID="meetings"
runat="server">
<ItemTemplate>
<%# Eval("MeetingName")%>
</ItemTemplate>
</asp:Repeater>
4. Expressions (not code) often DataSources: <%$.%>
Exmaple :
<asp:SqlDataSource ID="party" runat="server"
ConnectionString="<%$ ConnectionStrings:letsParty %>"
SelectCommand="SELECT * FROM [Employee]" />
5. Directive Tags <%@.%>
Directive Syntax - often at top of page for registering controls and page declaration
Exmaple :
<%@ Page Language="C#"
MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" Title="Untitled Page" %>
<%@ Register TagPrefix="wp" Namespace="CustomWebParts" %>
6. Server side comment Tag : <%--.--%>
This is a server side comment, stuff you don't want anyone without code access to see:
Example :
<asp:Label ID="lblAwesome" runat="server"/>
<%-- sometimes end users make me angry --%>
<asp:LinkButton ID="lbEdit" Text="Edit"
OnClick="Edit_Click" runat="server" />
7. <%: ... %> This tag is identical to the "<%= ... %>" tag except that it
auto-html-encodes the value within the tag
Exmaple :
<%: Html.TextBox("FirstName") %> // This will dispaly a text box with ID='FirstName'