Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

Creating Form at Runtime.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Javicho - 08 Jul 2005 16:17 GMT
Hi.
I want to create forms at runtime in asp.net a don´t know it´s posible to do
this.
And How to do it
Cowboy (Gregory A. Beamer) - MVP - 08 Jul 2005 17:43 GMT
You can populate a form using an ASPX page by adding controls to a container
(a Panel is a nice container, but even Page can be a container). If this is
what you mean by form (ie, a bunch of controls to fill in), you simply set up
a routine that dynamically creates controls and binds them to a container
(like a Panel, as mentioned above).

private void PaintForm()
{
   //assume proper reference to System.Web.UI.WebControls
  Label l = new Label();
  l.Text = "Name";
  Panel1.Controls.Add(l);

  TextBox t = new TextBox();
  t.ID = "txtName";
  t.Width = 50;
  t.MaxLength = 25;
  Panel1.Controls.Add(t);

  //Assume reference to System.Web.UI
  LiteralControl lc = new LiteralControl("<br>");
  Panel1.Controls.Add(lc);

  Button b = new Button();
  b.ID = "btnSubmit";
  b.Text = "Submit Name";

  //Add event handler  
  b.Click += new EventHandler(this.Button_Click);
}

NOTE: You will have to code in event handlers, like so:

private void Button_Click(object sender, EventArgs e)
{
}

Signature

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

> Hi.
> I want to create forms at runtime in asp.net a don´t know it´s posible to do
> this.
> And How to do it

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.