473,513 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a form dynamicly

Hi all,

I'm fairly new to ASP.NET. What i want to do is creat a online
registration form. On the first step is getting the users details and
the number of people he wants to register.
Based on the number of people i want to create a form where he can enter
the persons details.

For example he wants to register 3 people. Then the second step of the
registration would have to be like this :

Person1
Name :
E-mail :
Function :

Person2
Name :
E-mail :
Function :

Person3
Name :
E-mail :
Function :

How do i create this in .NET
I was thinking creating panels with the small forms dynamicly.
How do i that ? Where can if find info on doing this.

Thanks in advance

--
DaWoE
Nov 18 '05 #1
2 2001
Hi DaWoE,

Yes you are right you can use panels and depending on the number of people
you can add the control dynamically
to the panel and once user enters values..you can loop through the contols
and access those values.

but for this you need to make a post back to the server once user enters the
number of people.

Workaround to prevent a post back..what you can do is create some 10 div
tags <DIV> and make them visible is false initially
and when user enters the number of people in the TextBox ( i assume you use
textbox ) on textChange or lost focus of text box use javascript
to make the number of DIV tags visible = true..

This method seems to be little difficult but prevents a post back !

Hope this helps you.

Thanks
Raghavendra
"DaWoE" <da*******@yahoo.com> wrote in message
news:2p************@uni-berlin.de...
Hi all,

I'm fairly new to ASP.NET. What i want to do is creat a online
registration form. On the first step is getting the users details and
the number of people he wants to register.
Based on the number of people i want to create a form where he can enter
the persons details.

For example he wants to register 3 people. Then the second step of the
registration would have to be like this :

Person1
Name :
E-mail :
Function :

Person2
Name :
E-mail :
Function :

Person3
Name :
E-mail :
Function :

How do i create this in .NET
I was thinking creating panels with the small forms dynamicly.
How do i that ? Where can if find info on doing this.

Thanks in advance

--
DaWoE

Nov 18 '05 #2
Hi Raghavendra,

I did use a postpack. Here is the testcode that worked for me.

The aspx file :
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="test.aspx.vb"
Inherits="PlayInn.test"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>test</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:Panel id="Panel1" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button>
</asp:Panel>
<asp:Panel id="Panel2" runat="server" Visible="False">
<asp:Button id="Button2" runat="server" Text="Button"></asp:Button>
</asp:Panel>
</form>
</body>
</HTML>
The vb.file :
Public Class test
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Panel1 As System.Web.UI.WebControls.Panel
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Panel2 As System.Web.UI.WebControls.Panel
Protected WithEvents Button2 As System.Web.UI.WebControls.Button

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Protected Overrides Sub LoadViewState(ByVal savedState As Object)
MyBase.LoadViewState(savedState)
If ViewState("controlsadded") = True Then
AddControls()
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim liNumber As Int32
Dim liCount As Int32
Dim loLabel As Label
Dim loControl As Control

liNumber = CType(TextBox1.Text, Int32)
Session("Number") = liNumber
If ViewState("controlsadded") Is Nothing Then
AddControls()
End If

For liCount = 1 To liNumber
loLabel = New Label
loLabel = CType(Panel2.FindControl("label" & liCount), Label)
loLabel.Text = "This label" & liCount
Next
Panel1.Visible = False
Panel2.Visible = True
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim liCount As Int32
Dim loLabel As Label

For liCount = 1 To CType(TextBox1.Text, Int32)
loLabel = New Label
Try
loLabel = CType(Panel2.FindControl("label" & liCount),
Label)
Response.Write("Label" & liCount & ".text = " &
loLabel.Text & "<br>")
Catch ex As Exception
Response.Write(ex.Message & "<br>")
End Try
Panel2.Visible = False
Next
End Sub
Private Sub AddControls()
Dim liNumber As Int32
Dim liCount As Int32
Dim loLabel As Label

liNumber = Session("Number")

For liCount = 1 To liNumber
loLabel = New Label
loLabel.ID = "label" & liCount
loLabel.EnableViewState = True
Panel2.Controls.AddAt(liCount - 1, loLabel)
Next
ViewState("controlsadded") = True
End Sub
End Class
Raghavendra T V wrote:
Hi DaWoE,

Yes you are right you can use panels and depending on the number of people
you can add the control dynamically
to the panel and once user enters values..you can loop through the contols
and access those values.

but for this you need to make a post back to the server once user enters the
number of people.

Workaround to prevent a post back..what you can do is create some 10 div
tags <DIV> and make them visible is false initially
and when user enters the number of people in the TextBox ( i assume you use
textbox ) on textChange or lost focus of text box use javascript
to make the number of DIV tags visible = true..

This method seems to be little difficult but prevents a post back !

Hope this helps you.

Thanks
Raghavendra
"DaWoE" <da*******@yahoo.com> wrote in message
news:2p************@uni-berlin.de...
Hi all,

I'm fairly new to ASP.NET. What i want to do is creat a online
registration form. On the first step is getting the users details and
the number of people he wants to register.
Based on the number of people i want to create a form where he can enter
the persons details.

For example he wants to register 3 people. Then the second step of the
registration would have to be like this :

Person1
Name :
E-mail :
Function :

Person2
Name :
E-mail :
Function :

Person3
Name :
E-mail :
Function :

How do i create this in .NET
I was thinking creating panels with the small forms dynamicly.
How do i that ? Where can if find info on doing this.

Thanks in advance

--
DaWoE


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1324
by: Rhett | last post by:
Hello,guys! I need some idea for Creating controls accoring to configuration. The context. Some controls are configured by xml, and there's also some xml string to configure the layout of...
5
2388
by: Grisha0 | last post by:
Hi, i've got a little question. I'd like to create an object for example TextBox normaly it'd like look like this: TextBox my_Object = new TextBox(); but i'd like to get the name of the...
1
1789
by: Henke | last post by:
Hi I have a aspx-page with a panel-control. On this panel control I add user controls dynamicly with LoadControl and panel.Controls.Add(myControl). On some of the dynamicly added user controls I...
1
1340
by: chris | last post by:
I know I've asked this before, but I didn't really get an answer and I bet it's because I didn't explain myself very well. Here goes again. I have this code: Dim arrData(intNoOfRows,...
2
5035
by: filbennett | last post by:
Hi Everyone, I'm generally unfamiliar with Access form design, but have programmed Cold Fusion applications for a couple of years. I'd like to build a data entry form in Access that allows the...
1
2389
by: Rako | last post by:
My problem is: I want to create an index to any of the available picture-groups. This index is a table of thumbs with a scrollbar. If you click on the thumb, you get the full picture displayed. ...
0
1107
by: Owen Wong | last post by:
Is it possible to add a server-side form dynamicly?
7
2849
by: Aussie Rules | last post by:
Hi, Is there a way to have a screen/form designer functionality in a vb.net2008 program for the end user to use ? I want to be able to distribute my application, and allow the end user to...
3
1111
by: tedmoseby | last post by:
I am creating a website, using flash instances which will be dynamicly based on xml information (pulled from, the users, sql db; thru php). I am running into a problem, mapping this out on...
0
7260
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5089
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.