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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
jacksonm1234Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

jacksonm1234Commented:
Did you have any questions on my solution? I thought I gave you the answer you were looking for but maybe not...
0
lotusnotesnewbieCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.