943,795 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 258808
  • ASP.NET RSS
You are currently viewing page 13 of this multi-page discussion thread; Jump to the first page
Oct 18th, 2006
0

Re: Updated : Simple ASP.Net Login Page

Perahaps I am still a newbie but where do you put the imports @?
Thanks,
Mike
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikedopp is offline Offline
2 posts
since Oct 2006
Oct 19th, 2006
0

Re: Updated : Simple ASP.Net Login Page

Click to Expand / Collapse  Quote originally posted by mikedopp ...
Perahaps I am still a newbie but where do you put the imports @?
Thanks,
Mike

Hi Mike,

I would review the tutorial section at the top of this thread for the step by step procedure, but bascially the imports are placed at the top of the code behind page or top of the script section at the top of the page. Depending on the method you are using. ASP.NET 1.0 or 1.1 specifically.

Quote ...
b.Code the "meat" of the Login in page.
- Mine is in the code behind rather than a script block, but the principles are the same.
- Add the following Imports to your code behind, just above the class declaration.
Code:
Imports System.Web.Security ' ||||| Required Class for Authentication
Imports System.Data ' ||||| DB Accessing Import
Imports System.Data.OleDb ' |||||| Access Database Required Import!


Imports System.Configuration ' |||||| Required for Web.Config appSettings |||||


This will provide the library imports you need for Authentication, accessing an OleDB (i.e. Access), and accessing the web.config file (contains your connection string)
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Oct 19th, 2006
0

Re: Updated : Simple ASP.Net Login Page

Is there a way to use this code in visual web developer or Visual studio 2005 .net2.0?

Thanks,
Mike
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikedopp is offline Offline
2 posts
since Oct 2006
Oct 21st, 2006
0

Re: Updated : Simple ASP.Net Login Page

Click to Expand / Collapse  Quote originally posted by mikedopp ...
Is there a way to use this code in visual web developer or Visual studio 2005 .net2.0?

Thanks,
Mike
Hi Mike,

Visual Web Develper or Visual Studio 2005 is in ASP.Net 2.0 and not 1.1. So some modification of this code would need to be done, as there are some differences which makes this code non-functional.

I highly recommend you go to this link and watch and walkthrough the tutorial videos.

LINK


I plan to post a ASP.Net 2.0 login tutorial very soon, now that my work project has concluded.

Thanks
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Nov 13th, 2006
0

Re: Updated : Simple ASP.Net Login Page

hi paladin

can you send me the code modifications to make the login page in visual Studio 2.0?
becouse i wrote your code but when i debug the pc find some errors.

do you have code in 2.0 for login page?

thanks a lot

ponchohq@gmail.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ponchohq is offline Offline
3 posts
since Nov 2006
Nov 14th, 2006
0

Re: Updated : Simple ASP.Net Login Page

hi man

this is poncho. i wrote your code and made it run

but this line i can`t do work

SqlConnection(ConfigurationSettings.AppSettings("strConn"))

the debug send me an error

that say

sqlconnection is a type and can`t use like an expresion

if you can help me, i to be happy

i am development in visual studio 2005

contact: ponchohq@gmail.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ponchohq is offline Offline
3 posts
since Nov 2006
Feb 23rd, 2007
0

need help.....login for asp.net 2.0

hi..
Paladine i m using asp.net2.0 n was wonderin if u could provide the entire piece of this login page in asp.net 2.0 ...

thngs hav changed a bit in asp.net 2.0.....

would really appreciate if u continue this thread with asp.net2.0......

here is wat i did.....
tell me wat i did wrong !!!

[code]
LOGIN PAGE ....apsx file

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>

<!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>Login</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR" />
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE" />
<meta content="JavaScript" name="vs_defaultClientScript" />
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema" />
</head>
<body>
<!-- ||||| Login Form ||||| -->
<form id="frmlogin" method="post" runat="server">
<table id="mainTable">
<tr>
<td>
<table class="t_border" id="loginTable" cellspacing="15" cellpadding="0">
<tr>
<td><b>Login: </b>
</td>
<td><asp:textbox id="txtUserName" runat="server" width="160px"></asp:textbox><asp:requiredfieldvalidator id="rvUserValidator" runat="server" display="None" errormessage="You must supply a Username!"
controltovalidate="txtUserName"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td><b>Password: </b>
</td>
<td><asp:textbox id="txtPassword" runat="server" width="160px" textmode="Password"></asp:textbox><asp:requiredfieldvalidator id="rvPasswordValidator" runat="server" display="None" errormessage="Empty Passwords not accepted"
controltovalidate="txtPassword"></asp:requiredfieldvalidator></td>
</tr>
<tr>
<td align="center" colspan="2"><asp:button id="cmdSubmit" runat="server" borderstyle="Solid" text="Submit" OnClick ="button_click"></asp:button>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table id="messageDisplay">
<tr>
<td><asp:validationsummary id="Validationsummary1" runat="server" width="472px" displaymode="BulletList"></asp:validationsummary></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<asp:label id="lblMessage" runat="server" width="288px" forecolor="#C00000" font-size="Medium"
font-italic="True" font-bold="True"></asp:label>

</body>
</html>



[code]

aspx.vb file
[code]


Partial Class Default2
Inherits System.Web.UI.Page

Protected Sub button_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
If Page.IsValid Then ' ||||| Meaning the Control Validation was successful!
' ||||| Connect to Database for User Validation |||||
If DBConnection(txtUserName.Text.Trim(), txtPassword.Text.Trim()) Then
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
Response.Redirect("default.aspx")
Else

' ||||| Credentials are Invalid
lblMessage.Text = "Invalid Login!"
' ||||| Increment the LoginCount (attempts)
'Session("LoginCount") = CInt(Session("LoginCount")) + 1
' ||||| Determine the Number of Tries
'If Session("LoginCount").Equals(intMaxLoginAttempts) Then
' Response.Redirect("Denied.aspx")
'End If

'If CInt(Session("Num_of_Tries")) > 2 Then ' ||||| If Exceeds then Deny!
' Response.Redirect("Denied.aspx")
'End If

End If
End If
End Sub


Public Function DBConnection(ByVal strUserName As String, ByVal strPassword As String) As Boolean

Dim MyConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("HDconn").ConnectionString)
'HDconn is my connectiostring from web.config
Dim MyCmd As New System.Data.SqlClient.SqlCommand("StoredProcedure1", MyConn)

MyCmd.CommandType = Data.CommandType.StoredProcedure
Dim objParam1, objParam2 As Data.SqlClient.SqlParameter
Dim objReturnParam As Data.SqlClient.SqlParameter

objParam1 = MyCmd.Parameters.Add("@UserName", System.Data.SqlDbType.VarChar)
objParam2 = MyCmd.Parameters.Add("@Password", System.Data.SqlDbType.VarChar)
objReturnParam = MyCmd.Parameters.Add("@Num_of_User", System.Data.SqlDbType.Int)

objParam1.Direction = System.Data.ParameterDirection.Input
objParam2.Direction = System.Data.ParameterDirection.Input
objReturnParam.Direction = System.Data.ParameterDirection.ReturnValue
objParam1.Value = txtUserName.Text
objParam2.Value = txtPassword.Text

Try

If MyConn.State = System.Data.ConnectionState.Closed Then
MyConn.Open()
MyCmd.ExecuteNonQuery()
End If

If objReturnParam.Value < 1 Then
lblMessage.Text = "Invalid Login!"
Else
Return True
End If

MyConn.Close()


Catch ex As Exception
'lblMessage2.Text = "Error Connecting to Database!"
End Try


End Function


End Class


[code]


and this is wat i did in web.config

[code]
<appSettings/>
<connectionStrings>
<add name="HDconn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

[code]



but this thing always gives me......INVALID LOGIN.....
the table n stored procedure r exactly the same as u had posted earlier....


now can u plz tell me WHAT is exactly the prob.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maheshg is offline Offline
1 posts
since Feb 2007
Mar 29th, 2007
0

Re: Updated : Simple ASP.Net Login Page

Hi Paladine, that tutorial worked great and my login is now working from my Access DB

I don't know if i'm allowed to ask this question here, but here goes!

When the user has logged in and they are taken to the Default.aspx page i would like a 'Welcome [UserName goes here]' feature showing who they have successfully logged in as

I'm a complete newbie to ASP.Net and i'm sure it will be very easy for you to tell me

Thanks again

Rich
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Rich2701 is offline Offline
7 posts
since Mar 2007
Mar 29th, 2007
0

Re: Updated : Simple ASP.Net Login Page

Click to Expand / Collapse  Quote originally posted by Rich2701 ...
Hi Paladine, that tutorial worked great and my login is now working from my Access DB

I don't know if i'm allowed to ask this question here, but here goes!

When the user has logged in and they are taken to the Default.aspx page i would like a 'Welcome [UserName goes here]' feature showing who they have successfully logged in as

I'm a complete newbie to ASP.Net and i'm sure it will be very easy for you to tell me

Thanks again

Rich
No worries Rich,

Good question. See page 2 of this tutorial on how to do just what you asked.

http://www.daniweb.com/techtalkforum...ad19303-2.html
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Apr 20th, 2007
0

Re: Updated : Simple ASP.Net Login Page

Paladine, thanks for your help so far. As of now, my login pages load in Visual QWeb Developer Express (Only validation works, and when i login with user id and pw, the page just reloads with the pw text field blank again. I dont get an error connecting to database or anything). However, when I check it out on the server, i get a big configration error. It is something like :

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:

Line 6: Line 7: <system.web>Line 8: <roleManager enabled="true" />Line 9: <authentication mode="Forms" />Line 10: <compilation defaultLanguage="vb" debug="true" />

Below is my full web.config file. (not as same as yours, but does it need to be just with the source file location changed?)


<configuration>
<appSettings>
<addkey="strnConn"value="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=D:\Inetpub\wwwroot\students\teamg\IUser\teamg.mdb;User ID=Admin;Password=;" />
</appSettings>
<system.web>
<roleManagerenabled="False" />
<authenticationmode="Forms" />
<compilationdefaultLanguage="vb"debug="true" />
<customErrorsmode="Off" />
<traceenabled="true"requestLimit="10"pageOutput="true"traceMode="SortByTime"localOnly="false" />
</system.web>
<connectionStrings>
<addname="myConnection"connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Inetpub\wwwroot\students\teamg\IUser\teamg.mdb;Persist Security Info=True"

providerName="System.Data.OleDb"/>
</connectionStrings>
</configuration>



I have used your query for MS access, your same form code, and same functions in my login.aspx.vb file, (mostly cut and paste ). Im not sure what is causing this error?

Also, I would like to redirect a validaded user from my Acess Database to my menu.aspx page Any help would be appreciated .
Reputation Points: 10
Solved Threads: 0
Newbie Poster
benbujwah is offline Offline
1 posts
since Apr 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in ASP.NET Forum Timeline: Parent and Child Classes
Next Thread in ASP.NET Forum Timeline: Creating waiting page in ASP.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC