Click here to Skip to main content
15,923,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Master Page:

<body>
<form id="form1" runat="server">



<asp:HyperLink ID="HyperLink27" runat="server" ForeColor="White"
NavigateUrl="~/Login.aspx">[Sign in]



Master Page.cs file:

protected void Page_Load(object sender, EventArgs e)
{
string role=(string)(Session["userauthentication"]);
if (Session["userauthentication"] != null)
{
HyperLink3.NavigateUrl = "E_scan_request_IP.aspx";
HyperLink9.NavigateUrl = "scheuler_innovation.aspx";
}
else if (Session["userauthentication"] != null)
{
HyperLink3.NavigateUrl = "E_scan_request_IP.aspx";

}
else if (Session["userauthentication"] != null)
{
HyperLink9.NavigateUrl = "scheuler_innovation.aspx";
}

}

Login Page cs:

protected void Button1_Click(object sender, EventArgs e)
{
string role = DropDownList1.Text;
string username = TextBox1.Text;
string password = TextBox2.Text;
con.Close();
con.Open();
cmd = new SqlCommand("select * from schedule_login where Role='" + DropDownList1.Text + "' and Username='" + TextBox1.Text + "' and Password='" +TextBox2.Text + "'",con);
rd = cmd.ExecuteReader();
if (rd.Read())
{
Session["userauthentication"] = role;
Session.Timeout = 1;
Response.Redirect("Home.aspx");
}
else
{enter code here
Session["userauthentication"]="";
}

}

there are different roles according to that different hyperlink should be enabled and disabled... i'm getting problem in master page while its not storing session instring role=(string)(Session["userauthentication"]); please help me with this since i'm new to asp.net
Posted

1 solution

Hai
First u check Session["userauthentication"] using some varible,like
C#
String user =Session["userauthentication"] as String;


where u assign session ? in login page ? pls check u get value or not in login page itslef.if u get value then assign session and check in master page like this .get and cast
C#
String str= Session["userauthentication"] as String;



Regards
AravindB
 
Share this answer
 
Comments
Charan_Kumar 9-Dec-13 0:58am    
store user id in session.
and according to the user id give hyperlinks as enabled true/false.
Aravindba 9-Dec-13 22:36pm    
ok,try to use session what i mention,i think u declare wrong way.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900