German Wear Discount Shop - Click Here Write for Dotnet-friends and earn for your each submission [Dot]Net-Friends
Skip Navigation Links
Home
Latest
Fast Code
Articles
Tutorials
Online Resources
Forums
Login   | Hi, Guest


ActiveStepChanged Event of Wizard Controle and User Roles

Written by omerkamal on Dec 28, 2006
Article about ActiveStepChanged Event of Wizard Controle to Display Roles Informations

Introducation:

ASP .NET 2.0 Introduced new Wizard Control which reduces the tedious work for creating navigation and step by step Managment controles.
Here we will discuss about ActiveStepChanged Event of Wizard Controle and User Roles Informations displaying trick.

Explanation:

Let us see the Example by examining the Code.


Our .aspx Page ;











Our Code Behind; 

Protected Sub Wizard1_ActiveStepChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Wizard1.ActiveStepChanged
Dim c1 As New TableCell()
Dim c2 As New TableCell()
Dim row As New TableRow()

c1.Text = "Welcome!"
row.Cells.Add(c1)

If (Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.step2)) Then
If (Roles.IsUserInRole(User.Identity.Name, "Members")) Then
c2.Text = "Member"
Else
c2.Text = "Ananymous"
End If

row.Cells.Add(c2)
Table1.Rows.Add(row)
End If
End Sub

You noticed that we creating Table Row in the code behind and on the proper step we display the informations according to their Role.

One thing have to noted that to run get result from this code user have to be Signed-in. If you are admin and you want to get information for the users instead of displaying them to the Users then just use the User Name instead of "User.Identity.Name"

If (Roles.IsUserInRole(UserName, "Members")) Then
c2.Text = "Member"
Else
c2.Text = "Ananymous"
End If

Where "UserName" is either entered menually or taken From the Collection of all users i.e "Membership.GetAllUsers()"

Visitors/Readers Comments
(for questions please use The Forum)



Modi

good work

I Had problem with Wizard Controle. I searched the Internet but could not see such a stright example.

28/12/2006 12:01:10 UTC




Add your Comments

Name:  
Message:
Note: For faster response please use Forums >> for your questions instead of the comments area! (Admin)