Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamically generated webforms?

Reply
Thread Tools

Dynamically generated webforms?

 
 
Dave
Guest
Posts: n/a
 
      10-05-2004
Hi!

I'm an experienced C++ developer, but am new to ASP.NET. I need to develop
a database querying application that we need here, and would like to try to
do it in ASP.NET and C#.

The thing that I'm not sure is doable, is that I'd like to have support for
buttons on the form that, when clicked, will add new text input fields into
the form. So, the form needs to be dynamically "growable", using
self-modifying code within the ASP itself.

Can this be done?

TIA

- Dave


 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      10-05-2004
Yes you can. You can use the Controls.Add() method to add new controls to
the page.

Dim newText As New TextBox()
newText.ID = "myID"

Page.Controls.Add(newText)

One thing to remember is to re-create these controls on a postback, and be
able to maintain the state. For that, there is a great article at:

http://www.codeproject.com/aspnet/retainingstate.asp

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com


"Dave" <> wrote in message
news:...
> Hi!
>
> I'm an experienced C++ developer, but am new to ASP.NET. I need to

develop
> a database querying application that we need here, and would like to try

to
> do it in ASP.NET and C#.
>
> The thing that I'm not sure is doable, is that I'd like to have support

for
> buttons on the form that, when clicked, will add new text input fields

into
> the form. So, the form needs to be dynamically "growable", using
> self-modifying code within the ASP itself.
>
> Can this be done?
>
> TIA
>
> - Dave
>
>



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      10-05-2004
Yes. Fairly easily..here's some pseudo/real code:

void button_click(args){
TextBox t = new TextBox();
t.id = "userName";
APlaceHolderOnYourPage.Controls.Add(t);
}

You'll find the tricky thing is that those controls aren't "permenantly"
added to the page. That is, if you click the button again, or another
button, you need to re-add all items that were added. Denis Bauer has a
placeholder that is meant to help you do that (never used it)
http://www.denisbauer.com/ASPNETCont...aceholder.aspx or
you can simply track everything you added in the viewstate and then readd
those items before adding anything new (which is what his control probably
does for you).

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


"Dave" <> wrote in message
news:...
> Hi!
>
> I'm an experienced C++ developer, but am new to ASP.NET. I need to

develop
> a database querying application that we need here, and would like to try

to
> do it in ASP.NET and C#.
>
> The thing that I'm not sure is doable, is that I'd like to have support

for
> buttons on the form that, when clicked, will add new text input fields

into
> the form. So, the form needs to be dynamically "growable", using
> self-modifying code within the ASP itself.
>
> Can this be done?
>
> TIA
>
> - Dave
>
>



 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      10-05-2004
Thanks. I'll give this a shot and post back if I have any questions.

- Dave


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically generated page Matjaz Zalar ASP .Net 5 12-01-2003 05:06 PM
Dynamically generated URL's for search engines? Bruce W...1 ASP .Net 4 11-21-2003 04:46 PM
How to insert dynamically generated HTML into the <body> of an ASP.NET page? Rick Spiewak ASP .Net 5 08-01-2003 12:23 PM
Dynamically generated png images Chris Jones ASP .Net 1 06-27-2003 03:00 PM
.png doesn't work for dynamically generated images, but .jpeg and .gif does Chris Jones ASP .Net 0 06-25-2003 12:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57