Asp.net 3.5 Dynamic Controls

Any body have idea how to put controls dynamically in asp.net 3.5 ?if any example please provide to me.another Question : is it possible to create Event for Dynamic Controls ?

Here is an example (including creating an event) for ASP.NET dynamic controls…

protected void Page_Load(object sender, EventArgs e)
{
    Button button = new Button();
    button.Text = "Click me";
    button.Click += new EventHandler(ButtonClick);

    this.Form.Controls.Add(button);
}

private void ButtonClick(object sender, EventArgs e)
{
    (sender as Button).Text = "You just clicked me!";
}

Hope it helps!

It is certainly possible, and it’s possible to “wire up” a controls events despite it being created dynamically.

See the following links for full information:

Dynamic Controls in ASP.NET

How to: Add Controls to an ASP.NET Web Page Programmatically

Dynamic ASP.Net Control Creation Using C#.Net

How To Dynamically Add Controls to a Web Page Video

About eagle081183

Passionate, Loyal
This entry was posted in ASP.NET MVC, C#. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s