Ask a Question related to ASP.NET General, Design and Development.
-
Cowboy \(Gregory A. Beamer\) #1
Re: programatically create controls on the fly
The basic concept is this:
1. Add a container. You can use a generic container, like page, but a panel
(or other) is a better option:
<asp:panel id="panel1" name="panel1" />
2. Add controls to the panel
using System.Web.UI.WebControls;
//...
// rt = random Textbox
Textbox rt= new Textbox()
rt.ID = "text1";
// Add control(s) to panel
panel1.Controls.Add(rt);
Most likely, you will end up tweaking this for layout, et al, so you may
want to dynamically build a table with controls in it and attach the table
to the panel.
Another option is to create a user or server control that builds up the
section in question. You can then place that control on a page and feed it
property values to set the textboxes. NOTE that you will have to wire any
user controls in code behind to programatically assign property values.
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Author: ADO.NET and XML: ASP.NET on the Edge
************************************************** **************************
****
Think Outside the Box!
************************************************** **************************
****
"clark" <clark@speakeasyinteractive.com> wrote in message
news:0ebb01c35763$61be5bf0$a101280a@phx.gbl...> I have a form in which I would like to create a varying
> number of Textbox controls. I would to programmatically
> control their id and name.
> Do I need to create these controls at runtime? if so how?
> and can I name them something variable ie txtUser1,
> txtUser2,txtUser3, etc...
Cowboy \(Gregory A. Beamer\) Guest
-
ASP.NET 2 and custom controls!! How can i create them?
i can't find anything on the net to create a simple custom control with asp.net 2 and use it in other project..with that i mean having my own... -
Programatically created controls in an ascx user control misbehaving
Hello I have a need to dynamically (programatically) create various different controls (TextBox, RadioButtonList, CheckBox, etc.) at page_load... -
Problem adding composite controls programatically
"Stephen Richardson" <steve@richson64.freeserve.co.uk> wrote in message news:01a001c37ec7$9940ac50$a301280a@phx.gbl... Add a Placeholder control... -
How to create a datagrid programatically ?
Hi, Any examples / pointers on how to render a datagrid on the fly in a asp.net page, based on dynamic parameters ? Something like the way we... -
Can't create any more controls ...
I have created a form using tabs. After having added quite some controls and text fields to the tabs I get the message. 'Can't create any more...



Reply With Quote

