Posted by Shinna123 under ASP.NET on 6/24/2012 | Points: 10 | Views : 1069 | Status : [Member] | Replies : 2
i ve created a website in which there several role like sales,admin...

my task is that i want to allow nly sales person to add a new a/c

so for that i m logging in as sales n then sign up page opens which contains a create user wizard which has been customized to add an intermediate step but the problem here is this that this create user wizard never reaches the complete step.................i cant understnd wat is the problem....

plz help

thnx in advance


Posted by: Johnbhatt on: 6/24/2012 [Member] Starter | Points: 25

What is problem in Create User Page, please illustrate with Code.

John Bhatt
Glad to Know, Free to Share.....

Shinna123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shinna123 on: 6/25/2012 [Member] Starter | Points: 25

code behind :

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)
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)
End Using

End If

End Sub

End Class

inline code:

<%@ 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" "">

<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<asp:WizardStep ID="WizardStep1" runat="server" Title="User Profile">
<table style="width: 292px; height: 74px">
<td style="width: 84px; text-align: right; height: 26px;">
<asp:Label ID="Label1" runat="server" Text="First Name:" Width="84px"></asp:Label>
<td style="width: 79px; height: 26px;">
<asp:TextBox ID="tb_FirstName" runat="server" Width="173px"></asp:TextBox>
<td style="width: 84px; text-align: right">
<asp:Label ID="Label2" runat="server" Text="Last Name:" Width="86px"></asp:Label>
<td style="width: 79px">
<asp:TextBox ID="tb_LastName" runat="server" Width="173px"></asp:TextBox>
<td style="width: 84px; height: 21px; text-align: right">
<asp:Label ID="Label3" runat="server" Text="City:"></asp:Label>
<td style="width: 79px; height: 21px">
<asp:TextBox ID="tb_City" runat="server" Width="173px"></asp:TextBox>
<td style="width: 84px; text-align: right">
&nbsp;<asp:Label ID="Label4" runat="server" Text="State:"></asp:Label>
<td style="width: 79px">
<asp:DropDownList ID="ddl_Zip" runat="server" DataSourceID="SqlDataSource1" DataTextField="PostalCode"
DataValueField="PostalCode" Width="115px">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cs-ToolRental %>"
SelectCommand="SELECT [PostalCode] FROM [TR_PostalCode]"></asp:SqlDataSource>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">



Shinna123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response