This is a migrated thread and some comments may be shown as answers.

AuthorizeAttribute for a RadComboBox

2 Answers 53 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Nikola
Top achievements
Rank 2
Nikola asked on 01 Nov 2012, 08:39 AM
Heey Guys 

Is there an example of how to show a Combo Box item, say "Admin" only when a user acting in the role of administrator is currently logged in?

Thanks for help and fast answer ! `^

2 Answers, 1 is accepted

Sort by
0
Accepted
Kalina
Telerik team
answered on 06 Nov 2012, 11:49 AM
Hi Nikola,

You can populate the RadComboBox with all Roles in this way:
<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true"
    OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged">
</telerik:RadComboBox>

protected void Page_Load(object sender, EventArgs e)
{
    string[] usersInRole = Roles.GetAllRoles();
    RadComboBox1.DataSource = usersInRole;
    RadComboBox1.DataBind();
}

Then at SelectedIndexChanged you can check whether the currently logged user is in the Role that has been selected in the combo:
protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
     
    if (Roles.IsUserInRole(RadComboBox1.SelectedValue))
    {
        // perform some actions here...
    }
 
}



Regards,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nikola
Top achievements
Rank 2
answered on 06 Nov 2012, 01:50 PM

Heey

found it by my self but still thanks . Had the  same solution as you '^^

 

Tags
ComboBox
Asked by
Nikola
Top achievements
Rank 2
Answers by
Kalina
Telerik team
Nikola
Top achievements
Rank 2
Share this question
or