0

Once I have logged in, the "loggedIn.aspx" page is to display:
IP Address:
Contact:
Date:

I am able to get the IP address to display, but really have no clue on how to show both the username and current date.

This was a conversion from .asp to c#.net
Here is the code I have so far

Log in page

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="index1.WebForm1" %>

<!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 id="Head1" runat="server">
    <title>Audit Services Login</title>
    <style type="text/css">
        .style1
        {
            color: #000080;
        }
        .style2
        {
            width: 176px;
        }
         .style8
        {
            color:#FF0000;
            width: 176px;
        }
    </style>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<!-- ********* Top Logo *********** -->

    <tr>
        <td><img src="http://www.company.com/images/spacer.gif" height="1" width="20" alt="line"/>A Company Division</td>
        <td align="right">
        <!-- Display Date -->
<script type="text/javascript" language="javascript">
<!--    Begin
    d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
    m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);

    today = new Date();
    day = today.getDate();
    year = today.getYear();

    if (year < 2000)
        year = year + 1900;

    end = "th";
    if (day == 1 || day == 21 || day == 31) end = "st";
    if (day == 2 || day == 22) end = "nd";
    if (day == 3 || day == 23) end = "rd";
    day += end;

    document.write("<font face='Verdana, Arial, Helvetica' size='1'>");
    document.write(d[today.getDay()] + ", " + m[today.getMonth()] + " ");
    document.write(day + ", " + year);
    document.write("</font><img src='http://www.company.com/images/spacer.gif' height='1' width='20'>");
// End -->
</script>


        </td></tr>
        <tr><td valign="top" colspan="2"><img src="http://www.company.com/images/line.gif" height="1" width="100%" alt="line"/></td></tr>        
        </table>
        <table width="100%">
<tr>
    <td align="center" valign="top">
        <span class="style1">&nbsp;New users can </span> <a href="signup.aspx">
        <span class="style1">register here.</span></a><br />

    <form id="form1" runat="server">
    <div>
          <table border="3" cellpadding="0" cellspacing="1" 
              style="background-color: #EBEDEC; border-color: #C0C0C0; border-style: solid; border-width: 2px 20px 2px 20px">
<tr>
    <td>

<table border="0" width="230" cellpadding="4">
<tr>
        <td colspan="2" align="left">&nbsp;<strong style="color: #000080">Please Login.</strong></td>
    </tr>
    <tr>
        <td class="style2">
            <asp:Label ID="lbl_username" runat="server" Text="Username" style="color: #000080"></asp:Label></td>
        <td>
            <asp:TextBox ID="txt_username" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td class="style2">
            <asp:Label ID="lbl_pass" runat="server"  Text="Password" style="color: #000080"></asp:Label></td>
        <td>
            <asp:TextBox ID="txt_pass" TextMode="Password" runat="server"></asp:TextBox></td>
    </tr>
    <tr>
        <td colspan="2">
            <asp:Button ID="btn_submit" runat="server" Text="Login" onclick="btnSubmit_Click" ></asp:Button></td></tr>

    </tr>

</table>
<tr>
            <td class="style8" align="center"><asp:Label ID="labelMessage" runat="server" Text=""></asp:Label></td></tr>
</td>
</tr>
</table> 

    </div>
    </form>
    <br />

If you have difficulty accessing the system or cannot remember your username and password, please contact Company Support via email at <a href="mailto:support@company.com">support@company.com</a>.
<br /><br />
<em>Unauthorized access to this system is strictly prohibited.</em>
<br /><br /><br />
&nbsp;Contents Copyright © 2003 <a href="http://www.company.com">Company</a> All rights reserved. 
</td>
</tr>
</table> 

</body>
</html>

The code behind for it

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Configuration;


namespace index1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        //System.Data.OleDb.OleDbConnection con;
        //DataSet ds1;





        protected void Page_Load(object sender, EventArgs e)
        {

            //con = new System.Data.OleDb.OleDbConnection();
            //ds1 = new DataSet();


        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string connect = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=|DataDirectory|prosearchusers.mdb";
            string query = "Select Count(*) From CustRecords Where Cust_Name = ? And Cust_Password = ?";
            int result = 0;
            using (OleDbConnection conn = new OleDbConnection(connect))
            {
                using (OleDbCommand cmd = new OleDbCommand(query, conn))
                {
                    cmd.Parameters.AddWithValue("", txt_username.Text);
                    cmd.Parameters.AddWithValue("", txt_pass.Text);
                    conn.Open();
                    Session["Cust_Name"] = txt_username.Text;
                    result = (int)cmd.ExecuteScalar();
                }
            }
            if (result > 0)
            {
                Response.Redirect("loggedIn.aspx");
            }
            else
            {
                labelMessage.Visible = true;
                labelMessage.Text = "Incorrect username or password";


            }
        }
    }
}

Now the code for the LoggedIn.aspx page

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="loggedIn.aspx.cs" Inherits="web_login.loggedIn" %>

<!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>Audit Services</title>
</head>
<body>


<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<!-- ********* Top Logo *********** -->

    <tr>
        <td>A Company Division</td>

        <!-- Display Date -->
<script type="text/javascript" language="javascript">
<!-- Begin
d = new Array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
m = new Array(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
);

today = new Date();
day = today.getDate();
year = today.getYear();

if (year < 2000)    
year = year + 1900;

end = "th";
if (day==1 || day==21 || day==31) end="st";
if (day==2 || day==22) end="nd";
if (day==3 || day==23) end="rd";
day+=end;

document.write("<font face='Verdana, Arial, Helvetica' size='1'>");
document.write(d[today.getDay()]+", "+m[today.getMonth()]+" ");
document.write(day+", " + year);
document.write("</font><img src='http://www.company.com/images/spacer.gif' height='1' width='20'>");
// End -->
</script>


        </td></tr>
        <tr><td valign="top" colspan="2"><img src="http://www.company.com/images/line.gif" height="1" width="100%"></td></tr>

        </table>

            <table width="100%">

    <!-- ******************* Side Navigation ******************** -->



    <!-- ***************** Main Cell For Body ******************* -->    

<tr>
    <td align="center" valign="top">
            <table width="100%">
            <tr>
                        <td align="center" valign="top">


        <table border="0" cellpadding="0" cellspacing="1">
<tr>
    <td>
        <table>

<tr>
    <td align="right">Logged In:</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td align="right">IP Address:</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td align="right">Registered:</td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td align="right" colspan="2"><img src="http://www.Company.com/images/bullet.gif" width="13" height="13">&nbsp;<a href="http://www.company.com">Logout</a></td>
</tr>

</table>
</td>
</tr>
</table>

            </td>
            </tr>        


            <tr>
            <td align="center"><br/>


<form id ="form1" runat = "server">
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>




<table width="100%">
<tr>
    <td>Welcome to Company Online Services.
<br/><br/>
<img src="http://www.Company.com/images/bullet.gif" width="13" height="13">&nbsp;<a href="javascript:document.form1.submit();">Inquiry</a></form>
                <br/>If you have difficulty with the system, please contact Company Support via email at <a href="mailto:support@company.com">support@company.com</a>. Logging out does not prevent using the browsers back button from viewing past pages.  This can be prevented by closing the current browser window.
<br><br>
<div>&nbsp;Contents Copyright © 2003 <a href="http://www.company.com">Company</a>. All rights reserved.</div>

</td>
</tr>
</table>     


        </td>
    </tr>
</table>     
</body>
</html>

and the codebehind for Loggedin.aspx

using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace web_login
{
    public partial class loggedIn : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = Request.UserHostAddress;
            Label2.Text = Request.LogonUserIdentity;



        }
    }
}

Edited by __avd: Moved to ASP.NET forum

2
Contributors
1
Reply
9
Views
4 Years
Discussion Span
Last Post by LastMitch
0

@christie.smoot.3

I am able to get the IP address to display, but really have no clue on how to show both the username and current date.

If you want to display data from the database you have to do something like this:

Response.ContentType = "text/xml";
Response.Write("<root someAttribute = 'txt_username' />");
Response.Write("<root someAttribute = 'day + ", " + year' />");

or this:

<% Response.Write("txt_username"); %>
<% Response.Write("day + ", " + year"); %>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.