ProTech's home page

ProTech-Online.com

Microsoft c# ASPX code example for displaying panel if authenticated user role is admin.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Web.Security;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.AdminMessagePanel.Visible = false;
        try
        {
            if (Request.IsAuthenticated)
            {
                if (User.IsInRole("admin"))
                    this.AdminMessagePanel.Visible = true;
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
}


Copyright © 2013 ProTechs-Online.com; All rights reserved.