• Tagprefix like jQuery and Java Server pages Standard tag Library (JSTL)
  • WebControl.RenderContents Method 
    • Namespace: System.Web.UI.WebControls
      Assembly: System.Web (in System.Web.dll)
    • Renders the contents of the control to the specified writer.
    • This method is used primarily by control developers.

Step: 1

Add a class

Step: 2 Add a new Class

 

tagprefix.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//this is for Label Class
using System.Web.UI.WebControls;
using System.IO;
using System.Web.UI;


/// <summary>
/// Summary description for tagprefix
/// </summary>
namespace myAspNet.CS.Controls
{
public class tagprefix : Label
{
public tagprefix()
{
//
// TODO: Add constructor logic here
//
}
public string visitors
{
get
{
string s = (string)ViewState["visitors"];
return (s == null) ? String.Empty : s;
}
set
{
ViewState["visitors"] = value;
}
}

protected override void RenderContents(HtmlTextWriter writer)
{
writer.WriteEncodedText(Text);
if (Context != null)
{
string s = Context.User.Identity.Name;
if (s != null && s != String.Empty)
{
string[] split = s.Split('\\');
int n = split.Length - 1;
if (split[n] != String.Empty)
{
writer.Write(", ");
writer.Write(split[n]);
}
}
else
{
if (visitors != String.Empty)
{
writer.Write(", ");
writer.Write(visitors);
}
else
{
writer.Write("!");
}
}
}
}

}
}
 

Note the class is registered