i have created a webpage. i want that before entering in that page session should check that what is the role of user that is admin or user. i have put the following condition.
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Role"].ToString = "User")
{
Response.Redirect("Dataentry.aspx");
}
else
Response.Redirect("ControlPannel.aspx");
}
But it gives me the following error:
The name 'Session' does not exist in the current context
i have also used Session("Role") but gives the same error.
please tell me what is the problem.
Loading
Sandeep ShekhawatPosted Jun 24, 2011, 6:56 AM
protected void Page_Load(object sender, EventArgs e)
{
string Role=Session["Role"].ToString();
if (Role = "User")
{
Response.Redirect("Dataentry.aspx");
}
saifullah khanPosted Jun 24, 2011, 6:52 AM
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
saifullah khanPosted Jun 24, 2011, 6:35 AM
The left-hand side of an assignment must be a variable, property or indexer
Sandeep ShekhawatPosted Jun 24, 2011, 6:31 AM
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Role"].ToString() = "User")
{
Response.Redirect("Dataentry.aspx");
}