Solved

create server control dynamically in asp.net

Posted on 2013-12-13
1
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

707 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