为什么没有显示完整步骤?
源代码:
AddNewCustomer.aspx
<%@ Page Language="VB" MasterPageFile="~/Master/tool.master" AutoEventWireup="false" CodeFile="AddNewCustomer.aspx.vb" Inherits="sales_AddNewCustomer" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div>
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
</asp:CreateUserWizardStep>
<asp:WizardStep ID="WizardStep1" runat="server" Title="User Profile">
<table style="width: 292px; height: 74px">
<tr>
<td style="width: 84px; text-align: right; height: 26px;">
<asp:Label ID="Label1" runat="server" Text="First Name:" Width="84px"></asp:Label>
</td>
<td style="width: 79px; height: 26px;">
<asp:TextBox ID="tb_FirstName" runat="server" Width="173px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 84px; text-align: right">
<asp:Label ID="Label2" runat="server" Text="Last Name:" Width="86px"></asp:Label>
</td>
<td style="width: 79px">
<asp:TextBox ID="tb_LastName" runat="server" Width="173px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 84px; height: 21px; text-align: right">
<asp:Label ID="Label3" runat="server" Text="City:"></asp:Label>
</td>
<td style="width: 79px; height: 21px">
<asp:TextBox ID="tb_City" runat="server" Width="173px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 84px; text-align: right">
<asp:Label ID="Label4" runat="server" Text="State:"></asp:Label>
</td>
<td style="width: 79px">
<asp:DropDownList ID="ddl_Zip" runat="server" DataSourceID="SqlDataSource1" DataTextField="PostalCode"
DataValueField="PostalCode" Width="115px">
</asp:DropDownList>
</td>
</tr>
</table>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cs-ToolRental %>"
SelectCommand="SELECT [PostalCode] FROM [TR_PostalCode]"></asp:SqlDataSource>
</asp:WizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</div>
</asp:Content>
代码
Imports System.Data.SqlClient
Partial Class sales_AddNewCustomer
Inherits System.Web.UI.Page
Protected Sub CreateUserWizard1_ActiveStepChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.ActiveStepChanged
'Have we jst reached the complete Step?
If CreateUserWizard1.ActiveStep.Title = "Complete" Then
Dim UserSettings As WizardStep = CType(CreateUserWizard1.FindControl("UserProfileSettings"), WizardStep)
Dim FirstName As TextBox = CType(CreateUserWizard1.FindControl("tb_FirstName"), TextBox)
Dim LastName As TextBox = CType(CreateUserWizard1.FindControl("tb_LastName"), TextBox)
Dim City As TextBox = CType(CreateUserWizard1.FindControl("tb_City"), TextBox)
Dim strPostalCode As String = ddl_Zip.SelectedItem.Text
'Update the userprofile record for this user
'get the userid for the just added user
Dim newUser As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
Dim newUserID As Guid = CType(newUser.ProviderUserKey, Guid)
'add the newly created user to the customer role
Dim uName As String = CreateUserWizard1.UserName.ToString
Roles.AddUserToRole(uName, "customer")
'Insert a new record into UserProfile
Dim connectionstring As String = ConfigurationManager.ConnectionStrings("cs-ToolRental").ConnectionString
Dim updatesql As String = "insert into [TR_UserProfile] ([UserID],[FirstName],[LastName],[City],[PostalCode]) values(@UserId,@FirstName,@LastName,@City,@PostalCode)"
Using myconnection As New SqlConnection(connectionstring)
myconnection.Open()
Dim mycommand As New SqlCommand(updatesql, myconnection)
mycommand.Parameters.Add(New SqlParameter("@PostalCode", strPostalCode))
mycommand.Parameters.AddWithValue("@FirstName", FirstName.Text.Trim())
mycommand.Parameters.AddWithValue("@LastName", LastName.Text.Trim())
mycommand.Parameters.AddWithValue("@City", City.Text.Trim())
mycommand.Parameters.AddWithValue("@UserId", newUserID)
mycommand.ExecuteNonQuery()
myconnection.Close()
End Using
End If
End Sub
End Class