I'm trying to create a profile for a user as they are being created. There's a great example out there by Scott Guthrie that does exactly what I want. My program runs with no errors, but the profile data is not being saved. I'm really not sure what the problem is, so am hoping someone here can give me a hand. Here is my code.
In the web.config I have the profile defined as such:
Code:
<profile defaultProvider="BSGProfileProvider">
<providers>
<add
name="BSGProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="BSGNETDB" />
</providers>
<properties>
<add
name="Customer"
type="string" />
<add
name="ShipTo"
type="string" />
</properties>
</profile>
My aspx page looks as such:
Code:
<%@ Page Language="vb" Debug="true" %>
<script runat="server">
Sub CreateUserWizard1_CreatedUser(ByVal sender as Object, ByVal e as EventArgs)
Dim p as ProfileCommon = CType(ProfileCommon.Create(CreateUserWizard1.UserName, true), ProfileCommon)
Dim CustNum as TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("CustomerNum"), TextBox)
Dim ShipNum as TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShipNum"), TextBox)
p.Customer = CustNum.Text
p.ShipTo = ShipNum.Text
p.Save()
End Sub
Sub AssignUserToRoles_Activate(ByVal sender as Object, ByVal e as EventArgs)
AvailableRoles.DataSource = Roles.GetAllRoles()
AvailableRoles.DataBind()
End Sub
Sub AssignUserToRoles_Deactivate(ByVal sender as Object, ByVal e as EventArgs)
Roles.AddUserToRole(CreateUserWizard1.UserName, AvailableRoles.SelectedValue)
End Sub
</script>
<html>
<head>
<title>Create User</title>
<link rel="stylesheet" type="text/css" href="~/common/portal.css">
</head>
<body bgcolor="#000000" text="#FFFFFF" topmargin="0" marginheight="0" leftmargin="0" marginwidth="0" rightmargin="0" leftmargin="0" bottommargin="0">
<form id="CreateUserForm" runat="server">
<div align="center"><br><br><br><br>
<asp:CreateUserWizard id="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep id="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<asp:Table id="CreateUser" runat="server"
Width="100%" CellPadding="0" CellSpacing="0" BackColor="#D7D7D7">
<asp:TableRow>
<asp:TableCell ColumnSpan="2" BackColor="#6B696B" Style="color: white;">
Create UserID
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="50%" HorizontalAlign="right" Style="color: black;">
<asp:Label id="lblUserName" runat="server"
Text="User Name: " AssociatedControlID="UserName" />
</asp:TableCell>
<asp:TableCell Width="50%">
<asp:TextBox id="UserName" runat="server" />
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="50%" HorizontalAlign="right" Style="color: black;">
<asp:Label id="lblEmail" runat="server"
Text="E-mail Address: " AssociatedControlID="Email" />
</asp:TableCell>
<asp:TableCell Width="50%">
<asp:TextBox id="Email" runat="server" />
<asp:RequiredFieldValidator ID="EmailRequired" runat="server"
ControlToValidate="Email" ErrorMessage="Email is required."
ToolTip="Email is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="50%" HorizontalAlign="right" Style="color: black;">
<asp:Label id="lblPassword" runat="server"
Text="Password: " AssociatedControlID="Password" />
</asp:TableCell>
<asp:TableCell Width="50%">
<asp:TextBox id="Password" runat="server"
TextMode="Password" />
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="50%" HorizontalAlign="right" Style="color: black;">
<asp:Label id="lblConfirmPassword" runat="server"
Text="Re-type Password: " AssociatedControlID="ConfirmPassword" />
</asp:TableCell>
<asp:TableCell Width="50%">
<asp:TextBox id="ConfirmPassword" runat="server"
TextMode="Password" />
<asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword" ErrorMessage="Confirm Password is required."
ToolTip="Confrim Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2" BackColor="#6B696B" Style="color: white;">
Enter Customer Info
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="50%" HorizontalAlign="right" Style="color: black;">
<asp:Label id="lblCustomerNum" runat="server"
Text="Enter Customer #: " AssociatedControlID="CustomerNum" />
</asp:TableCell>
<asp:TableCell Width="50%">
<asp:TextBox id="CustomerNum" runat="server" />
<asp:RequiredFieldValidator ID="CustomerNumRequired" runat="server"
ControlToValidate="CustomerNum" ErrorMessage="Customer # is required."
ToolTip="Customer # is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="50%" HorizontalAlign="right" Style="color: black;">
<asp:Label id="lblShipToNum" runat="server"
Text="Enter Ship To #: " AssociatedControlID="ShipToNum" />
</asp:TableCell>
<asp:TableCell Width="50%">
<asp:TextBox id="ShipToNum" runat="server" />
<asp:RequiredFieldValidator ID="ShipToNumRequired" runat="server"
ControlToValidate="ShipToNum" ErrorMessage="Ship To # is required."
ToolTip="Ship To # is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2">
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToCompare="Password" ControlToValidate="ConfirmPassword"
Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="CreateUserWizard1" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan="2" Style="color: red;">
<asp:Literal EnableViewState="False" ID="ErrorMessage" runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:WizardStep id="AssignUserToRoles" runat="server"
AllowReturn="False" Title="Assign User To Roles"
OnActivate="AssignUserToRoles_Activate" OnDeactivate="AssignUserToRoles_Deactivate">
<asp:Table id="CreateUser" runat="server"
Width="100%" CellPadding="0" CellSpacing="0" BackColor="#D7D7D7">
<asp:TableRow>
<asp:TableCell Width="100%" HorizontalAlign="center" Style="color: black;">
<asp:Label id="lblAssignRoles" runat="server"
Text="Select a role for the user." />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Width="100%" HorizontalAlign="center">
<asp:ListBox id="AvailableRoles" runat="server" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</asp:WizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</div>
</form>
</body>
</html>