Hi phonghue,
On button click you are redirecting before assigning session.
You have to first assign session and then redirect to page.
I have created a sample. Now take its reference and correct your code.
HTML
Page1
<table>
<tr>
<td><p class="padding2"><asp:LinkButton ID="lnkIndexAdminComp" runat="server" OnClick="OnIndexAdmin">* Administrative/Computer</asp:LinkButton></p></td>
<td><asp:Label ID="lblAdmin" runat="server" Text="1" Font-Size="28px" Font-Names="Arial" Visible="false"></asp:Label></td>
</tr>
<tr>
<td><p class="padding2"><asp:LinkButton ID="lnkIndexChildYouth" runat="server" OnClick="OnIndexChild">* Child/Youth</asp:LinkButton></p></td>
<td><asp:Label ID="lblChild" runat="server" Text="2" Font-Size="28px" Font-Names="Arial" Visible="false"></asp:Label></td>
</tr>
</table>
Page2
Message : <asp:Label ID="lblMessage" Text="" runat="server" />
Code
C#
Page1
protected void OnIndexAdmin(object sender, EventArgs e)
{
Session["message"] = lblAdmin.Text;
Response.Redirect("~/GlobalAgencyTemplate.aspx");
}
protected void OnIndexChild(object sender, EventArgs e)
{
Session["message"] = lblChild.Text;
Response.Redirect("~/GlobalAgencyTemplate.aspx");
}
Page2
if (Session["message"] != null)
{
if (Session["message"].ToString() == "1")
{
lblMessage.Text = "Adminstrative/Computer";
}
else if (Session["message"].ToString() == "2")
{
lblMessage.Text = "CHILD/YOUTH";
}
}
else
{
lblMessage.Text = "";
}
VB.Net
Page1
Protected Sub OnIndexAdmin(ByVal sender As Object, ByVal e As EventArgs) Handles lnkIndexAdminComp.Click
Session("message") = lblAdmin.Text
Response.Redirect("GlobalAgencyTemplate.aspx")
End Sub
Protected Sub OnIndexChild(ByVal sender As Object, ByVal e As EventArgs) Handles lnkIndexChildYouth.Click
Session("message") = lblChild.Text
Response.Redirect("GlobalAgencyTemplate.aspx")
End Sub
Page2
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Session("message") IsNot Nothing Then
If Session("message") = "One" Then
lblMessage.Text = "Adminstrative/Computer"
ElseIf Session("message") = "Two" Then
lblMessage.Text = "CHILD/YOUTH"
End If
Else
lblMessage.Text = ""
End If
End Sub
Screenshot