C
C Downey
I have a registration form that should load different web user controls
based on the selection of a dropdown list. Basically, the user follows the
following steps:
1. user comes to very basic web form, no controls loaded
2. user selects registration type (1 of 4 possible types) from a dropdown
control
3. the dropdown properties are :
autopostback=True OnSelectedIndexChanged="displayUserGroupControl"
4. Now when my displayUserGroupControl fires I would like to load the
control based on their selection.
What is the best way to do this? When the user submits the form I will
create a new "user" record in my database as well as new records in other
tables based on their UserGroup control. Is it fairly easy to get
dynamically loaded controls to talk to each other?
Any tips or best practices would be much appreciated. If I have to, I can
change all the controls to tables in my main form and just hide them based
on the user selection but then the code gets a little hard to read.
Heres what I have right now - I want to confirm that Im doing this the best
way before heading down the wrong road.
Public Sub displayUserGroupControl(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Dim tblName As String
Dim selectValue As String = lbUserType.SelectedItem.Value
Select Case selectValue
Case "1"
phProfilesAndInterests.Controls.Add(LoadControl("controls/register_practitio
ner.ascx"))
Case "2"
phProfilesAndInterests.Controls.Add(LoadControl("controls/register_student.a
scx"))
Case ...
End Select
' Response.Write(selectValue.ToString + "|||<BR>")
End Sub
based on the selection of a dropdown list. Basically, the user follows the
following steps:
1. user comes to very basic web form, no controls loaded
2. user selects registration type (1 of 4 possible types) from a dropdown
control
3. the dropdown properties are :
autopostback=True OnSelectedIndexChanged="displayUserGroupControl"
4. Now when my displayUserGroupControl fires I would like to load the
control based on their selection.
What is the best way to do this? When the user submits the form I will
create a new "user" record in my database as well as new records in other
tables based on their UserGroup control. Is it fairly easy to get
dynamically loaded controls to talk to each other?
Any tips or best practices would be much appreciated. If I have to, I can
change all the controls to tables in my main form and just hide them based
on the user selection but then the code gets a little hard to read.
Heres what I have right now - I want to confirm that Im doing this the best
way before heading down the wrong road.
Public Sub displayUserGroupControl(ByVal sender As System.Object, ByVal e
As System.EventArgs)
Dim tblName As String
Dim selectValue As String = lbUserType.SelectedItem.Value
Select Case selectValue
Case "1"
phProfilesAndInterests.Controls.Add(LoadControl("controls/register_practitio
ner.ascx"))
Case "2"
phProfilesAndInterests.Controls.Add(LoadControl("controls/register_student.a
scx"))
Case ...
End Select
' Response.Write(selectValue.ToString + "|||<BR>")
End Sub