![]() |
| ||
| ASP.NET Registration Page This is a continuation of the Updated: ASP.NET Login Page Tutorial. This tutorial will demonstrate how to create a registration page for new users to your site. This registration page will utilize the same principles used in the Login Page Tutorial, so this should be no more difficult to do than the login page. I am using the SQL Server 2000, and programmed this part of the application in Visual Studio .NET 2003. I choose VB because it is more natural language to me, but there is no reason you can't use the same concepts I use here to code this in any other language in the .NET framework. 1. Create the basic HTML layout for the registration page. REGISTER.ASPX - This page will require all entries to be filled in for a successful registration - UserName, Password, FirstName and LastName <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Register.aspx.vb" Inherits="NorthLogin3.Register"%> 2. Create the Store Procedures you will need to add a new user - You will need to handle duplicates - You will need to handle the adding of a new user. a. Check for Duplicates. SP_CHECKFORDUPLICATES CREATE PROCEDURE sp_CheckForDuplicates b. Add New User. SP_REGISTERNEWUSER CREATE PROCEDURE sp_RegisterNewUser 4. Create the code behind to provide functionality to your registration page. REGISTER.ASPX.VB - This code behind will do several things; Validate the entries for completeness, duplication, and add the new user. - I test for duplicates in UserName, as well as First & Last Name. Imports System.Web.Security ' |||||| Required Class for Authentication 5. Final thing to do: Link the Registration Page to the Login Page - I used a Hyperlink on the login page to do this, but you could use anything. It is just a simple <a href="Register.aspx" ...> line of code to use for this. On that note I also send the user right back to the login page on successful registration. This is not the ideal thing to do. It would be better to direct them to a page that said "You are now registered! Would you like to return to the login page?" and a means of allowing them to return to the login page. But you specific use of this may be different, so the choice is yours. 6. Compile and run..... Happy coding :cool: |
| ||
| Re: ASP.NET Registration Page Nice this is good stuff Paladine. Miller |
| ||
| Re: ASP.NET Registration Page Hi I have tried to add more fields ie: Address, Phone, Email etc everything compiles ok but when running the app it comes up with the database error (lblError) I have updated the Stored procedure and the database with the correct fields so i think i know it is not that. any way here is codebehind: Imports System.Web.Security ' |||| Required Class for Authentication |
| ||
| Re: ASP.NET Registration Page OK, couple of things. 1. Please use code blocks "[code"]["/code]" for displaying your code. 2. Please provide the error message you are getting 3. You have the "strConn" variable listed in the web.config file correct? 4. Are you able to login in? 5. Please provide the code for the stored procedure. 6. Looking are your code, if you have added the extra variables to stored procedure, then why are you not passing them in to it? You show that you are adding 11 parameters to the collection, but onlying passing in 4 ? Although that is unlikely to cause an error unless they are "required fields". :cool: |
| ||
| Re: ASP.NET Registration Page Quote:
Hi Thanks for getting back to me. Ok answer to question 2 is "Error Connecting to DataBase!" and also asks for a *Required field at the bottom as well, this was supplied! i am not getting a specific .net output error just a page error lblError.text message response. Q3, strConn is listed in the web.config file. Q4, I am able to log in ok Q5, here is the stored procedure: Q6, I see what you are saying and tried to add them but VS said that it wasn't declared so i tried to add it, which would of been on lines 76, 83 and 90 for example but it still wanted to be declared! do i need to add the fields into this section ? ( as in txtAddress.text.trim()... ) etc etc. Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
|
| ||
| Re: ASP.NET Registration Page Ok. Thanks that helps clear things up. With regards to the additional fields... of course they are not declared. Look the the AddUser Parameters, you are only declaring three things, but requesting more. Understanding the code you are copying from is important. The number of parameters in your subroutine or function must be equal to the number of parameters/values you pass into it. (some exceptions, but that is more detail that won't help). So if you want to add strEmail etc, you have to add it to the parameters of the your subroutine. And you have to pass it in. Logic!! Make sense? As for your error, I would have to go line by line (so put in break points) and see where it fails, and what values it is passing around. Looking at the code, it looks sound to me. Hope this helps. |
| ||
| Re: ASP.NET Registration Page Just one quick one on stored procedure names... dont prefix a stored procedure with sp_ use anything but this as when you call a stored procedure SQL Server looks at the name and if it starts with sp_ it will go to the master database first, do a search for the stored proc and only when it fails will it then look in your database. It can be a big performance hit. |
| ||
| Re: ASP.NET Registration Page I was wondering how this would convert over for lets say an access database? Ive tried to convert it over, but its a no go. |
| All times are GMT -4. The time now is 10:53 am. |
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC