Create Html Controls Create Html Controls HtmlGenerci Controls

Do you want to create Html controls dynamically? Here are we will see very basic Html Generic Controls. We will create Div,P,and button controls of HTML.

Let's see how to create html meta tag using Html Generic control class.

  protected void Button1_Click(object sender, EventArgs e)
    HtmlGenericControl meta = new HtmlGenericControl("meta");
    meta.Attributes.Add("content","This is meta descccription");       
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class HtmlGenericControlExamples : System.Web.UI.Page
  protected void Button1_Click(object sender, EventArgs e)
    HtmlGenericControl button = new HtmlGenericControl("input");
    button.Attributes.Add("style", "height:20px;width:120px;");
    button.Attributes.Add("value", "Button control");
    button.Attributes.Add("type", "button");
    button.ID = "button1";


  protected void Button2_Click(object sender, EventArgs e)
    HtmlGenericControl divControl = new HtmlGenericControl("div");
    divControl.Attributes.Add("style", "height:220px;width:520px;");    
    divControl.InnerText = "This is div text";
    divControl.ID = "sampleDiv";

  protected void Button3_Click(object sender, EventArgs e)
    HtmlGenericControl pControl = new HtmlGenericControl("p");
    pControl.Attributes.Add("style", "height:120px;width:220px;");
    pControl.InnerText = "This text inside Paragraph";
    pControl.ID = "sampleP";



html without using tables tableless html table less html css tableless How to display HTML Create Folder On HTML5 Generate Article TagC# HtmlTextWriter ExampleBasic HTML5 TagsHow To Access Div, Iframe Html Controls Using code access html control textbox element value at code 2.0 step by step Membership Provider HTML5 With DataBaseCreate contact us form


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.