Solved

create server control dynamically in asp.net

Posted on 2013-12-13
1
334 Views
Last Modified: 2013-12-16
I have multiple forms and each form has its own page. I want to combine them to a single page and have server control gets create dynamically. Should I store each control id, name in sql? When page loads, how to it bind each control to value from db?  How should I go about doing something like this?  It could be done!
0
Comment
Question by:VBdotnet2005
1 Comment
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
ID: 39718450
Controls are nothing but class in .NET.

Say for example, if you want to adde a text box dynamically in to a server control C, you could follow below code.

TextBox txtBox = new TextBox();

txtBox.ID ="txtOption" + Rand().ToString();
txtBox.Width= Unit.Pixel(45);
txtBox.MaxLength = 2;

c.Controls.Add(txtBox);

//Then finally the server control could be added to page.

Page.Controls.Add(c);

Please do refer

 http://www.codeproject.com/Articles/14450/Dynamic-creation-of-ASP-NET-server-controls-on-fly

http://couldbedone.blogspot.in/2007/06/dynamically-created-controls-in-aspnet.html

http://www.dreamincode.net/forums/topic/328007-add-aspnet-controls-dynamically/

for more information.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET reading ATOM 2 52
Name space syntax error 12 44
Reset asp.net login password 4 34
ASP.net show message while code is running 3 9
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now