Implementing ASP.NET Server Side Controls through Code

There are scenarios that you might face where you cannot find out the actual number of server controls that needs to be added to the web page.

Under such circumstances you might need to add the server controls dynamically. The number of controls that are added is determined by some other factor or value that you get when the application is run.

You can create controls dynamically and add it to the web page when required. For this purpose you need to place a placeholder in the page during the design time.

The placeholder is the place where the server controls will be added during runtime. In the code you will determine which type of control is going to be added to the placeholder.

For example if you are going to add a textbox control with value “This is dynamically added”, to the placeholder placeholderTB, then the code would look like,

Dim Author As New TextBox
Author.Text = “This is dynamically added”
placeholderTB.Controls.Add(Author)

You can also add events to these server controls that you created dynamically.




______________________________________________________

Recommended Resource



| Why should you go for Server Controls | Advantages of using .NET Server Controls | Understanding ASP.NET Server Controls | Creating Web Server Controls | Server Side Controls in ASP.Net | Creating Custom Server Controls | Server Controls in ASP.NET Web Page | Using Html Server Controls in your Web Pages | Understanding Dynamic Server Controls in ASP.NET | Using ASP Server Controls Templates | Developing ASP.NET Server Controls | Setting properties for ASP.NET Custom Server Controls | Implementing ASP.NET Server Side Controls | Creating Professional ASP.NET Server Controls |

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.