[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 517
  • Last Modified:

hide the login link and put the logout link?

I have the login link that stays in the page.

<div id="mainnav-side">
    <ul>
      <li><a href="Login.aspx" title="Click here to login.">Login</a></li>
    </ul>
  </div>
  <div class="clear"></div>

I would like to fix this by hiding and putting logout link when the person is logged in.
Here is my code:
this is in my login.aspx page which has the master page connected.
 
   Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        Dim sql As New StringBuilder()
        Dim rep As Boolean = False
        sql.Append("select count(*) from tbl_dotnet_user where szUserName='" + txtUsername.Text.Trim() + "' and szPassword='" + txtPassword.Text.Trim() + "'")
        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim cmd As New SqlCommand(sql.ToString(), conn)
        conn.Open()
        rep = Convert.ToBoolean(CInt(cmd.ExecuteScalar()))
        conn.Close()
        SqlConnection.ClearPool(conn)
 
        If (rep) Then
            Session("UserID") = txtName.Text.Trim()
            Server.Transfer("interviews.aspx")
        Else
            lblErrorMessage.Text = "Wrong Username or password. Please try again."
        End If
 
    End Sub
 
 
 
 
 
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>KORE Telematics - GO .NET! Project Portal</title>
    <link rel="shortcut icon" href="themes/default/favicon.ico" />
    <link href="themes/default/msvs_template_simple_divs.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    
    <!-- 
  
  TOP NAV
  
  -->
<div id="mainnav-container">
  <div id="mainnav"><div class="none"><a href="#maincontent">skip to the main content area of this page</a></div>
    <ul>
      <li><a href="#" title="Users will see this text when they roll over this link. Keep it short and consise. Use this text to clarify the purpose of the link.">Home</a></li>
      <li><a href="#" title="Users will see this text when they roll over this link. Keep it short and consise. Use this text to clarify the purpose of the link.">News</a>&nbsp;</li>
      <li><a href="#" title="Users will see this text when they roll over this link. Keep it short and consise. Use this text to clarify the purpose of the link.">
          Milestones</a></li>
      <li><a href="#" title="Users will see this text when they roll over this link. Keep it short and consise. Use this text to clarify the purpose of the link.">
          Feedback</a></li>
    </ul>
  </div>
  <div id="mainnav-side">
    <ul>
      <li><a href="Login.aspx" title="Click here to login.">Login</a></li>
    </ul>
  </div>
  <div class="clear"></div>
</div>
<!-- 
  
  SITE NAME & SLOGAN
  
  -->
<div id="header">
<div style="float:left; width:505px;">
<a href="#" title="Site name home page">GO</a> .NET!
    <div id="slogan">
        The .NET Platform Implementation Portal</div>
        </div>
</div>
<div id="breadcrumb-container" style=" height:30px">
  <div id="breadcrumb"><a href="Default.aspx" title="Users will see this text when they roll over this link. Keep it short and consise. Use this text to clarify the purpose of the link.">Home</a>&nbsp;</div>
  <div id="breadcrumb-side">
    &nbsp;<b>Welcome 
        <asp:Label ID="lblUserID" runat="server" Text=""></asp:Label></b>
  </div>
 
   
 
  <div class="clear"></div>
</div>
<!-- 
 
  CONTENT
 
  --><div id="content-container">
  <!-- 
	
	SIDE COLUMN
	
	-->
  <div id="content-side" style="left: 0px; top: 0px">
    <ul class="link-list-vertical">
      <li><a href="interviews.aspx" title="Interview Forms">
          Interview Forms</a></li>
      <li><a href="screenshots.aspx" title="View Screenshots">
          Screenshots</a></li>
      <li><a href="templates.aspx" title="View Templates">
          Templates</a></li>
      <li><a href="samples.aspx" title="Viwe Smaples">
          Samples</a></li>
      <li><a href="reviews.aspx" title="Project Reviews">
          Reviews</a></li>
    </ul>
  </div>
  <!-- 
	
	MAIN COLUMN
	
	-->
  <div id="content">
  <div style="width:100%;  height: 50px;">
  <div style="float:left; width:10%; height: 50px;">
    <h1>
        <img src="images/kore_logo_white.jpg" alt="KORE Telematics" />&nbsp;</h1>
  </div>
  <div style="float:right; width: 80%; height: 50px; vertical-align:text-bottom;">
          <asp:ContentPlaceHolder ID="headertitle" runat="server">
          </asp:ContentPlaceHolder>
      <asp:Label ID="lblAgentID" runat="server" Text="0" Visible="False"></asp:Label></div>
        
   </div>
   
   <p>&nbsp;</p>
     <div style="width:90%px;">
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
    </div>
	<!-- 
	
  FOOTER
  
  -->
<div id="footer">
  <p>&copy; 2008. KORE Telematics. All rights reserved.<br />
      <span style="font-size: 10pt; color: black; font-family: 'Arial','sans-serif'; mso-fareast-font-family: Calibri;
          mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US;
          mso-bidi-language: AR-SA"><em>The information in this web portal is confidential and
              is intended solely for the addressee. Access to this web portal by anyone else is
              unauthorized. If you are not an authorized user, any disclosure, copying, distribution,
              or any action taken or omitted to be taken in reliance on it, is prohibited. Credentials
              to access this portal is restricted only to KORE Telematics agents.</em></span></p>
    <p>
        <span style="font-size: 10pt; color: black; font-family: 'Arial','sans-serif'; mso-fareast-font-family: Calibri;
            mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US;
            mso-bidi-language: AR-SA"><em></em></span>
        <img src="images/images.jpg" />&nbsp;<br />
    </p>
</div>
  </div>
  <!-- 
	
	SIDE 2 COLUMN
	
	-->
  <div id="content-side-2">
    <p><b>ASP.NET RSS</b></p>
    
  </div>
</div>
</form>
</body>
</html>

Open in new window

0
mathieu_cupryk
Asked:
mathieu_cupryk
  • 7
  • 4
1 Solution
 
amxCommented:
You could use two HyperlInk controls, one for login and one for log out.

Set the visibilty of the login hyperlink to true and the log out to false

Once they have logged in you can set the login visibility to false and the logout to true
0
 
mathieu_cuprykAuthor Commented:
can you show me how to do this with my code above.
0
 
amxCommented:
Like this...
<div id="mainnav-side">
    <ul>
      <li>
<asp:LinkButton ID="LinkButton1"  Visible="true" runat="server">Login</asp:LinkButton>
<asp:LinkButton ID="LinkButton2"  Visible="false" runat="server">Logout</asp:LinkButton>
</li>
    </ul>
  </div>
  <div class="clear"></div>
 
 
 
If (rep) Then
            Session("UserID") = txtName.Text.Trim()
            Server.Transfer("interviews.aspx")
LinkButton1.Visible = false;
LinkButton2.Visible = true;
        Else
            lblErrorMessage.Text = "Wrong Username or password. Please try again."
        End If

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mathieu_cuprykAuthor Commented:
the only thing is that I have to reference the
is the from master page

for the LinkButton1 and Linkbutton2?

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>
0
 
amxCommented:
So are you saying

1) LinkButtons are on the aspx page and you're calling them from the master page?
2) LinkButons are on the master page and you need to call them from the aspx page?

or something else?
0
 
mathieu_cuprykAuthor Commented:
#1)
0
 
mathieu_cuprykAuthor Commented:
Dim LinkButton1 As LinkButton = DirectCast(Master.FindControl("LinkButton1"), LinkButton)
        Dim LinkButton2 As LinkButton = DirectCast(Master.FindControl("LinkButton2"), LinkButton)

?is this ok
0
 
mathieu_cuprykAuthor Commented:
i mean number 2
0
 
amxCommented:
(Master.FindControl("LinkButton1") as LinkButton).Visible = true;
0
 
mathieu_cuprykAuthor Commented:
The problem when I click on the link button is that it does not transfer me to the login.aspx
0
 
mathieu_cuprykAuthor Commented:
Me.Page.Master.FindControl("LinkButton1").Visible = True
            Me.Page.Master.FindControl("LinkButton2").Visible = False
IS this it is still not hind it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now