Solved

create server control dynamically in asp.net

Posted on 2013-12-13
1
339 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Save ms data to server side. 19 59
VB.NET Textbox input validation 4 66
Testing of the web services 1 50
asp Google Map 2 63
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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