Easy question to put a logout button instead of a link.

if you got to omegalove.com
and try
username:mathieu
password:cupryk

U will get a logout linkbutton.
I would like to change this to a button.
<%@ Control Language="C#" AutoEventWireup="true"  CodeFile="Login.ascx.cs" Inherits="Controls_Login" %>
          <link href="../App_Themes/PlainHtml/Default.css" rel="stylesheet"
    type="text/css" />
          <div id="loginbox">
            <asp:LoginView ID="LoginView1" runat="server">
            <AnonymousTemplate>
               <asp:Login ID="Login" runat="server"
                    DestinationPageUrl="~/Profile.aspx" FailureAction="RedirectToLoginPage"
                    Height="31px">
                  <LayoutTemplate>
                   <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                           <td>
                           <asp:Label runat="server" ID="lblUserName" AssociatedControlID="UserName" Text="Username:"  />
                           <asp:TextBox id="UserName" runat="server" BorderColor="DarkGray"
                                   BorderStyle="Inset" BorderWidth="2px" />
                           <asp:RequiredFieldValidator ID="valRequireUserName" runat="server" SetFocusOnError="True"
                                 ControlToValidate="UserName" Text="*" ValidationGroup="Login"  />                    
                               <asp:Label ID="lblPassword" runat="server" AssociatedControlID="Password"
                                   Text="Password:" />
                               <asp:TextBox ID="Password" runat="server" TextMode="Password"
                                   BorderColor="DarkGray" BorderStyle="Inset" BorderWidth="2px" />
                               <asp:RequiredFieldValidator ID="valRequirePassword" runat="server"
                                   ControlToValidate="Password" SetFocusOnError="True" Text="*"
                                   ValidationGroup="Login" />
&nbsp;<asp:Button CssClass="blackButton2"  validationgroup="Login" CommandName="Login"
                                        ID="Submit" runat="server" Text="Login" Font-Bold="True" />
                              </td>
                           
                        </tr>
                        <tr>
                            <td>
                                <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me"
                              ForeColor="DarkSlateGray"></asp:CheckBox>&nbsp;|&nbsp;<asp:HyperLink ID="lnkPasswordRecovery" runat="server" NavigateUrl="~/PasswordRecovery.aspx">Forgot
                                password?</asp:HyperLink>
                            </td>
                           
                        </tr>
                     </table>
                  </LayoutTemplate>
               </asp:Login>
            </AnonymousTemplate>
           
            <LoggedInTemplate>
               <div id="welcomebox">
                  <asp:LoginName ID="LoginName1" runat="server" FormatString="Hello      {0}" /><br />
                  <small>
                  <asp:HyperLink ID="lnkProfile" runat="server" Text="Edit Profile" NavigateUrl="~/EditProfile.aspx" /><br />
                  <asp:LoginStatus ID="LoginStatus1" Runat="server" />
                  </small>
               </div>
            </LoggedInTemplate>
         </asp:LoginView>
        </div>

     
     
mathieu_cuprykAsked:
Who is Participating?
 
jacksonm1234Connect With a Mentor Commented:
Instead of using the LoginStatus control, just put a regular button in its place that says "logout". Set its "visible" property to False.

When the page loads, check to see if the user is logged in by using the "User.Identity.IsAuthenticated" property. If it returns true, then you can set your new button's visible property to true.

In then event handler for your new button, you simply need to put "FormsAuthentication.SignOut()" to manually sign the user out. I'll attach some code so it will make more sense. I hope it helps!
ASPX code:
<asp:LinkButton ID=lnkLogout runat=server Text="Logout" Visible=False></asp:LinkButton>
 
 
Form_Load code.
 
If Not Page.IsPostBack Then
            If User.Identity.IsAuthenticated Then
                lnkLogout.Visible = True
                
            Else
                lnkLogout.Visible = False
                
            End If
        End If
 
Button code. Notice that I used a link button, but a regular button will do.
 
Protected Sub lnkLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkLogout.Click
        FormsAuthentication.SignOut()
        
    End Sub

Open in new window

0
 
lotusnotesnewbieCommented:
Could you use a button image instead of  a button and change the Login status control like <asp:LoginStatus ID="LoginStatus1" runat="server" LoginImageUrl="~/images/<button image>.gif" />
0
 
mathieu_cuprykAuthor Commented:
lotus if you try to login to omegalove.com
with mathieu and password cupryk
u will see the button not working well.
<asp:LoginStatus ID="LoginStatus1" Runat="server" CssClass="blackButton2" Font-Bold />
                 
Can you give me a hand.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
jacksonm1234Commented:
Did you have any questions on my solution? I thought I gave you the answer you were looking for but maybe not...
0
 
lotusnotesnewbieConnect With a Mentor Commented:
Could you add this to your CSS file
A.blackButton2:link {
TEXT-DECORATION: none
}
A.blackButton2:hover {
TEXT-DECORATION: none
}
and remove Font-Bold in your <asp:LoginStatus ID="LoginStatus1" Runat="server" CssClass="blackButton2" Font-Bold /> You are almost there just modify the CSS a little you will get it like the buttons you have below.
Happy Coding!
0
 
mathieu_cuprykAuthor Commented:
jack and lotus it is still not working.
Any help would be great
0
 
mathieu_cuprykAuthor Commented:
try username accopaper
password omegalove
it is still not the right size I would like to put the font color to white instead of having orange and red.
0
 
mathieu_cuprykAuthor Commented:
any answers?
0
 
jacksonm1234Commented:
Did you try my solution?  
0
 
mathieu_cuprykAuthor Commented:
actual I had to use a button.
0
 
lotusnotesnewbieCommented:
Was just back will look into it and let you know before today
0
 
lotusnotesnewbieCommented:
let me know if this helps

<asp:LoginStatus ID="LoginStatus1" runat="server" LoginImageUrl="~/images/login.png" LogoutImageUrl="~/images/logout.png"/>  - No CSS required. Just two button like images.
0
 
mathieu_cuprykAuthor Commented:
I already implement go to omegalove.com
type username: macupryk
password: cupryk
0
 
lotusnotesnewbieCommented:
:) pardon me
0
 
mathieu_cuprykAuthor Commented:
no worries.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.