TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
271
36.4k
logout using link button in asp.net c#
Jul 29 2020 12:50 AM
i want when user click on logout its logout and it shows again Register and login option..
here is my code..
<div
class
=
"collapse navbar-collapse"
id=
"bs-example-navbar-collapse-1"
>
<ul
class
=
"nav navbar-nav navbar-right"
>
<li><a href=
"#page-top"
class
=
"page-scroll"
>Home</a></li>
<li><a href=
"#about"
class
=
"page-scroll"
>About</a></li>
<li><a href=
"#contact"
class
=
"page-scroll"
>Contact</a></li>
<div
class
=
"dropdown"
>
<asp:LinkButton ID=
"lnkUserName"
runat=
"server"
Text=
"Register Her...!"
OnCommand=
"lnkUserName_Command"
></asp:LinkButton>
<div
class
=
"dropdown-content"
>
<asp:LinkButton ID=
"LinkButton1"
runat=
"server"
Text=
"Login...!"
OnCommand=
"LinkButton1_Command"
></asp:LinkButton>
</div>
</div>
</ul>
</div>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(Session[
"UserName"
]!=
null
)
{
string
query =
"select * from User where UserName'"
+ Session[
"UserName"
] +
"'"
;
lnkUserName.Text =
string
.Format(
"Welcome {0}"
, Session[
"UserName"
].ToString());
LinkButton1.Text =
string
.Format(
"Logout"
);
lnkUserName.PostBackUrl =
"Profile.aspx"
;
}
}
protected
void
lnkUserName_Command(
object
sender, CommandEventArgs e)
{
Response.Redirect(
"/SignIn.aspx"
);
}
protected
void
LinkButton1_Command(
object
sender, CommandEventArgs e)
{
if
(LinkButton1.Text ==
"Logout"
)
{
Session[
"UserName"
] =
""
;
Response.Redirect(
"/Walpaper.aspx"
);
}
else
{
Response.Redirect(
"/Login.aspx"
);
}
Reply
Answers (
7
)
Save record in database using linq.
cannot implicitly convert type 'string' to 'system.web.httppostedfileb