using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
public partial class LabelControl : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Create Label dynamically
CreataLabel();
}
private void CreataLabel()
{
//limit to Label textbox
int a = 15;
for (int i = 0; i < a; i++)
{
Label lblDynamic = new Label();
//Declaring the textbox ID name
lblDynamic.ID = "lbl" + "" + ViewState["MyLebel"] + i + "<br/>";
lblDynamic.Width = 400;
lblDynamic.Height = 20;
lblDynamic.Text = "Label" + " " + i + "<br/>";
lblDynamic.BorderStyle = BorderStyle.Solid;
lblDynamic.Style["Top"] = "25px";
lblDynamic.Style["Left"] = "100px";
lblDynamic.BackColor = Color.DarkKhaki;
lblDynamic.BorderColor = Color.DarkOliveGreen;
form1.Controls.Add(lblDynamic);
}
}
}