Friday, October 12, 2012

Insert a HTML Tag into webpage in c#

This code will insert a specified tag into the webpage programatically.
public static void GenerateJsTag(this TemplateControl page, string jsCode)
{
 var jsLink = new HtmlGenericControl {TagName = "script", InnerHtml = jsCode }; jsLink.Attributes.Add("type", "text/javascript");
 page.Controls.Add(jsLink);
}

No comments:

Post a Comment