I am trying to create a logout button through dynamically generated HTML (string).
htmlGen = "<div class=\"issue\" style=\"float:right; width:70%;\">";
htmlGen += "Welcome, " + Page.User.Identity.Name.ToString() + " (<a href=\"#\" id=\"LogOutLink\" onclick=\"<%=LogOut_OnClick%>\"> logout </a>)";
As you can see, the logout method is in the server code:
public void LogOut_OnClick(object sender, EventArgs args) {
FormsAuthentication.SignOut();
string htmlGen = "<div class=\"issue\" style=\"float:right; width:45%;\">";
htmlGen += "<a style=\"color:White;\" href=\"/Login.aspx\">Login</a>";
htmlGen += " | <a style=\"color:White;\" href=\"/Accounts/SignUp.aspx\">Register</a>";
this.Literal1.Text = htmlGen + "</div>";
FormsAuthentication.RedirectToLoginPage();
}
No matter what i do, this doesn't seem to work (won't fire, won't log out, etc). Is there something about doing this as an HTML string to a literal that is causing this?
Would somebody mind telling me how to do this?
Thanks!