hii i need to use linkbutton(Go for more detail)......on that / button i need to check session values .if session variable on that page exist..it should redirect to a different page...but if session on that does not exist..it should be redirected to a login page.....my / button is within datalist control....
i m using following code in / button.....but somehow is not working....please help me out....thanks in advance............
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (Session["uname"] == null)
{
Response.Redirect("Login.aspx");
}
else
{
if (Session["type"].ToString() == "Candidate")
{
Response.Redirect("student/jobdetail.aspx");
}
else if (Session["type"].ToString() == "Branch")
{
Response.Redirect("admin/jobdetail.aspx");
}
}
}
below is my aspx page...........code
<asp:DataList ID="DataList1" runat="server" Width="100%" BorderStyle="Solid" BorderWidth="2px"
CellPadding="5" CellSpacing="5" BackColor="White">
<ItemTemplate>
<table style="text-align: left; height: 149px;" width="100%">
<tr>
<td width="20%">
<asp:Label ID="Label6" runat="server" Text='<%# Eval("CompanyName") %>' Font-Bold="True"
ForeColor="Blue"></asp:Label>
</td>
<td width="20%" align="center" class="td1">
<asp:Label ID="Label7" runat="server" Text='<%# Eval("Location") %>'></asp:Label>
</td>
<td width="20%" align="center" class="td1">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("PostName") %>'></asp:Label>
</td>
<td width="20%" align="center" class="td1">
<asp:Label ID="Label14" runat="server" Text='<%# Eval("Qualification") %>'></asp:Label>
</td>
<td width="20%" align="center" class="td1">
<asp:Label ID="Label15" runat="server" Text='<%# Eval("PostingDate") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click"
PostBackUrl='<%# "student/jobdetail.aspx?id=" + Eval("id") %>''>Apply
Now</asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click"
PostBackUrl=''<%# "jobdetail.aspx?id=" + Eval("id") + "&uid=" + Eval("userid") %>''>View
Detail</asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="5">
<hr />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>