Access Session value in other page using C# and VB.Net in ASP.Net

Last Reply 2 months ago By arunkurmi

Posted 2 months ago

Hello,

I have the code below that carry from another page, but then somehow only read the first “If statement”, and can’t pass it on to the second "If Statement" if is not true.

Please help.

Page 1:

HTML:

<table>
    <tr>
        <td>
            <p class="padding2">
                <asp:LinkButton ID="IndexAdminComp" runat="server">* Administrative/Computer</asp:LinkButton></p>
        </td>
        <td>
            <asp:Label ID="AdminComplbl" runat="server" Text="1" Font-Size="28px" Font-Names="Arial"
                Visible="false"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <p class="padding2">
                <asp:LinkButton ID="IndexChildYouth" runat="server">* Child/Youth</asp:LinkButton></p>
        </td>
        <td>
            <asp:Label ID="ChildYouthlbl" runat="server" Text="2" Font-Size="28px" Font-Names="Arial"
                Visible="false"></asp:Label>
        </td>
    </tr>
</table>

VB Code:

Protected Sub IndexAdminComp_Click(sender As Object, e As EventArgs) Handles IndexAdminComp.Click
    Response.Redirect("~/Agency/Report/GlobalAgencyTemplate.aspx")
    Session("One") = AdminComplbl.Text
End Sub 

Protected Sub IndexChildYouth_Click(sender As Object, e As EventArgs) Handles IndexChildYouth.Click
    Session("Two") = ChildYouthlbl.Text
    Response.Redirect("~/Agency/Report/GlobalAgencyTemplate.aspx")
End Sub

Page 2:

HTML:

<table>
    <tr>
        <td>
            <p class="padding10">
                <asp:Label ID="AClbl" runat="server" Text="" Font-Size="24px" Font-Bold="true"></asp:Label></p>
        </td>
</table>

VB Code:  here is the place that can't read the second "If"

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If AClbl.Text = Session("Two") Then
        GetFieldwork("QChildYouthService_sp")
        AClbl.Text = "CHILD/YOUTH"
    End If
    If AClbl.Text = Session("One") Then
        GetFieldwork("QAdministrativeComputers_sp")
        AClbl.Text = "Adminstrative/Computer"
    End If
End Sub

 

This question does not have replies marked as Answer.