ASP.Net: Showing buttons only to logged in users -


i want show few buttons users logged in. don't use membership provider session.

can still somehow use loggedintemplateor should other way?

i store session user in onlogin button event:

sqlcommand query = new sqlcommand("select count(*) admin     username='"+username.text+"' , password='"+password.text+"'", conn);      conn.open();     int result = (int)query.executescalar();     conn.close();       if (result > 0){         session["loggedin"] = true;         session["user"]=username.text;     }     else session["loggedin"] = false; 

then try create button if user logged in:

if ((bool)session["loggedin"]==true)) button_dodaj_oglas.visible = true;     else button_dodaj_oglas.visible = false; 

but objject not set instance (concerning session). wtf?

you can use session store loggedin-status although not recommend it, because session is not authentication.

bool loggedin = session["loggedin"] != null && (bool)session["loggedin"]; button1.visible = loggedin; 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -