C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
ASPX markup that uses asp Literal
<ul>
<li><asp:Literal runat="server" ID="FeaturedCount1"/>
articles</li>
<li><asp:Literal runat="server" ID="CategoryCount1" />
<i><asp:Literal runat="server" ID="CategoryText1" /></i>
articles similar to this one</li>
Code file for ASPX markup: C#
public partial class SiteHome : MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
// Set the bottom article count message.
FeaturedCount1.Text = SiteStructure.Instance.MapCount.ToString();
// FeaturedCountSpan1.Text = "50";
string categoryName = "Category"; // Just for example.
int countCat = SiteStructure.Instance.CountCategory();
CategoryCount1.Text = countCat.ToString(); // "5"
CategoryText1.Text = categoryName; // "Category"
}
}
Output HTML
<ul>
<li>50 articles</li>
<li>5
<i>Category</i>
articles similar to this one</li>
</ul>
Note: This method is efficient for client browsers to render, and also smaller for your bandwidth. The next section examines this.
Tip: This will create a nice and clear markup comment. Make an asp Literal with an ID of Comment1.
Comment example statement: C#
// Shows HTML comment in ASP.NET.
Comment1.Text = "<!-- HTML comment with literal. -->";
And: It will help you keep your code logical and easy-to-maintain. It reduces DOM elements and helps with client and server performance.
LiteralControl