Question

I have an application in which a user fills out a form indicating their interest in a service. This includes contact info. (e.g. name, email). They are then redirected to a page with a CreateUserWizard control - the idea being that it will prepopulate the form with most of the info. needed to create a user account (excluding username/password which need to be entered manually).

What I'd like to do is have the CreateUserWizard control not show these fields at all (for them to be prepopulated invisibly), so all the user sees is that they need to enter a username and password. There are two ways I can see achieving this:

Using Subroutine: I could use a subroutine like CreateUserWizard_CreatedUser to add the info. programmatically. I'm not sure if CreatedUser is the best place to add this info.?

Using Hidden Fields: I imagine I could add hidden fields to the CreateUserWizard control layout and somehow tell the control to look in these invisible fields for info. like name and email?

I'm looking for recommendations on the best way to accomplish this and any ideas on how to actually implement.

Était-ce utile?

La solution

When the user fills out the contact information form and clicks submit, you could store that information in Session variables (here, "phoneNum" and "email" would be your contact info TextBoxs):

Session("name") = phoneNum.Text
Session("email") = email.Text

This way, you can easily access those values from the page code where your CreateUserWizard exists.

It sounds like you would most likely want to handle the Creating User event in order to place those values in the appropriate controls on your CreateUserWizard before the CreateUser method is called on the Membership Provider. Something like this:

Protected Sub RegisterUser_CreatingUser(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles RegisterUser.CreatingUser
    RegisterUser.Email = Session("email").ToString()
    RegisterUser.UserName = Session("name").ToString()
End Sub

("RegisterUser" being the name of your CreateUserWizard control)

Let me know if you have any questions.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top