Streamlining Processes

CrackerJack

New member
Joined
Feb 27, 2006
Messages
1
Programming Experience
1-3
Here's the situation. I'm creating a registration module for my website, and I don't want to use any wizards or anything that makes life easier. My goal is to truly understand everything that needs to happen, and the only way I can do that is to program it from scratch. In my file I'm making multiple trips to the server, and I'm hoping to some how cut that down if at all possible. Please help.

Here's the general contents of my register.aspx and the codebehind register.aspx.vb file: (for the sake of time (since I'm at work and don't have the files in front of me) I've listed them in shorthand)

Register.aspx:

1)Username Textbox w/ <customvalidator onServervalidate="validate_username"> - User name must be unique in the database
2)Email Textbox w/ <customvalidator onServerValidate="validate_email"> - Email address has to be unique in the database
3)Drop down list of states from database
4)Contact info textboxes w/ standard validators

Register.aspx.vb

Sub Page_Load(....)
populate_ddl(...)
if page.ispostback then
page.validate()
if Page.Isvalid then
create_new_user(username as string, email as string, contctinfo ect...)
end if
end if
end sub

sub populate_ddl()
1) open database
2) select states
3) bind to ddl
sub

Sub validate_username(.....)
1) connect to the database
2) check for existing username
3) if not unique send error, else page is valid
end sub

Sub validate_email(.....)
1) connect to the database
2) check for existing email
3) if not unique send error, else page is valid
end sub

Sub create_new_user(username as string, email as string, contact info etc)
1) connect to the database
2) insert info
end sub

.:CrackerJack:.
 
Since you have to access your backend system for the validators, you will have to have server-side calls, unless you pass all valid entries to the client so the validation can occur client-side, which has obvious security issues.

My reco would be to use CustomValidators that do client-side validation, but the validation method could do an AJAX call back to the server to complete the validation. This way you get the appearance to the user that the page is not constantly refreshing, but behind the scenes you're getting the callbacks to the server like you need.

If you're looking for a quick way to get AJAX going, I would highly recommend the free AJAX.NET library: http://ajax.schwarz-interactive.de/csharpsample/default.aspx
 
Back
Top