jeudi 1 juin 2017

Unable to find session with IF asp.net C#

I have a database with a entry called Sally which is also link with asp login . When Sally logs I coded that it will gave a session["name"] which is Sally's database column name. When Sally logs in I made it so that "Label" will display the session's value (Sally) which it works. However, when pressing the "sally button" (to see if session is sally) it does not work. I assume its my code that is wrong but l cant find a solution. example of my "sally button code".

if (Convert.ToString(Session["group"]) == "Sally")
    {
        Label1.Text = "isSally";
    }
    else
    {
        Label1.Text = "notSally";
    }

It will always show "notSally" even thought the label will say sally once she logs in. I made another button which will change the label to see if the session["name"] is null, it works as when sally logs in it shows that there a session. Sorry for bad english. Sample of what it looks like

Aucun commentaire:

Enregistrer un commentaire