How to hide button according to user login in asp.net -
i have sort of problem hide button after user login. below snap/image explains problem:
in above image, see both user i.e "wajid" , "aamir" have visible of edit button.
now want if "wajid" login edit button show wajid not "aamir".
during login session is:
session["username"]
i tried this, not work:
string sessionname=session["username"].tostring(); if (sessionname == firstname) { (int = 0; <dealpointscommentlist1.items.count; i++) { edit =(linkbutton)dealpointscommentlist1.items[i].findcontrol("editcommentlnkbtn"); edit.visible =true; } } else { (int = 0; < dealpointscommentlist1.items.count; i++) { edit =(linkbutton)dealpointscommentlist1.items[i].findcontrol("editcommentlnkbtn"); } edit.visible = false; }
kindly reply me , provide sort of example.
try code.
string sessionname=session["username"].tostring(); if (sessionname == firstname) { (int = 0; <dealpointscommentlist1.items.count; i++) { labelname = (label)dealpointscommentlist1.items[i].findcontrol("lblfirstname"); if(labelname.text == sessionname) { edit = (linkbutton)dealpointscommentlist1.items[i].findcontrol("editcommentlnkbtn"); edit.visible =true; } else { edit =(linkbutton)dealpointscommentlist1.items[i].findcontrol("editcommentlnkbtn"); edit.visible =false; } } } else { (int = 0; < dealpointscommentlist1.items.count; i++) { edit =(linkbutton)dealpointscommentlist1.items[i].findcontrol("editcommentlnkbtn"); } edit.visible = false; }
hope helps.
Comments
Post a Comment