473,383 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

how would *you* do this?

I have several pages that will contain forms used for registering with
our website. These form won't always show the same information, as
their primary purposes are different, but part of the processing will
be the registration.

I'd like to have just one method for the entire site that handles the
creation of new account, referenced by all these forms.

So, assuming that form 'a' contains 8 fields required for registration,
form 'b' contains the min of 4, form 'c' contains 7 and form 'd' has
all 11, how would you create the method and then use it?

I'm new to C#, so bear with me. I've heard of overloading, but I think
I'd basically need 4 copies of the same method, which seems somewhat
over the top. I wondered about putting the form fields into an object
of some kind and then passing that object to the registration method.
Would that work?

What do you think would be the best way to get varying ammount of data
into a single method? Any examples and/or tutorial sites would be
greatly appreciated.

Thanks

Kevin

Sep 12 '06 #1
5 1135
Kevin,

I think that your second suggestion is the better one. Have a class
that exposes the fields from the form as properties, then pass that to your
registration method. I would also recommend implementing that method in a
library, then reference the library from the pages/project.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin Blount" <ke**********@gmail.comwrote in message
news:11*********************@d34g2000cwd.googlegro ups.com...
>I have several pages that will contain forms used for registering with
our website. These form won't always show the same information, as
their primary purposes are different, but part of the processing will
be the registration.

I'd like to have just one method for the entire site that handles the
creation of new account, referenced by all these forms.

So, assuming that form 'a' contains 8 fields required for registration,
form 'b' contains the min of 4, form 'c' contains 7 and form 'd' has
all 11, how would you create the method and then use it?

I'm new to C#, so bear with me. I've heard of overloading, but I think
I'd basically need 4 copies of the same method, which seems somewhat
over the top. I wondered about putting the form fields into an object
of some kind and then passing that object to the registration method.
Would that work?

What do you think would be the best way to get varying ammount of data
into a single method? Any examples and/or tutorial sites would be
greatly appreciated.

Thanks

Kevin

Sep 12 '06 #2
OK...

That part I wrote about being new though.. I don't get what you mean.
Any sample code or URL's you can offer? At the very least what keywords
should I Goggle for?

Thanks

Kevin

Nicholas Paldino [.NET/C# MVP] wrote:
Kevin,

I think that your second suggestion is the better one. Have a class
that exposes the fields from the form as properties, then pass that to your
registration method. I would also recommend implementing that method in a
library, then reference the library from the pages/project.

Hope this helps.
Sep 12 '06 #3
Kevin,

It's simple. You have a class that acts as your parameter list, which
has the parameters from the form:

public class RegistrationParameters
{
private string username;

private string password;

public string UserName
{
get
{
return username;
}
set
{
username = value;
}
}

public string Password
{
get
{
return password;
}
set
{
password = value;
}
}

// And so on...
}

Then, you have a method on another class:

public void Register(RegistrationParameters parameters)
{
// Use the fields that are set on the parameters instance
// of RegistrationParameters.
}
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kevin Blount" <ke**********@LOLgmail.comwrote in message
news:Oi**************@TK2MSFTNGP06.phx.gbl...
OK...

That part I wrote about being new though.. I don't get what you mean. Any
sample code or URL's you can offer? At the very least what keywords should
I Goggle for?

Thanks

Kevin

Nicholas Paldino [.NET/C# MVP] wrote:
>Kevin,

I think that your second suggestion is the better one. Have a class
that exposes the fields from the form as properties, then pass that to
your registration method. I would also recommend implementing that
method in a library, then reference the library from the pages/project.

Hope this helps.

Sep 12 '06 #4
Thanks for the sample code. I guess it is simple once you know how..
until then however...

;)

Nicholas Paldino [.NET/C# MVP] wrote:
Kevin,

It's simple. You have a class that acts as your parameter list, which
has the parameters from the form:

public class RegistrationParameters
{
private string username;

private string password;

public string UserName
{
get
{
return username;
}
set
{
username = value;
}
}

public string Password
{
get
{
return password;
}
set
{
password = value;
}
}

// And so on...
}

Then, you have a method on another class:

public void Register(RegistrationParameters parameters)
{
// Use the fields that are set on the parameters instance
// of RegistrationParameters.
}

Sep 12 '06 #5

This is how I would do this:

1. Create a base interface for all the information is required to create
a user. (IUserCreationRequest)

2. Create extension interfaces for other criteria that can be used to create
a user. (IAddress2Source, ITitleSource)

3. Create one method/service that takes in the base request and returns a
reference to the user.

4. Have every aspect create its own value object that implements at least
the base interface and also any other interfaces for data it can provide:

e.g:
public class CreateGuestUser : IUserCreationRequest ...
public class CreateInternalUser : IUserCreationRequest, IAddress2Source,
ITitleSource

5. Have the method/service create the basic user object and then populate
any extra data on it based on the interfaces the incoming request implements.

public IUser CreateUser(IUserCreationRequest userRequest)
{
IUser user = CreateUser(userRequest);

if (userRequest is IAddress2Source)
ApplyAddress2Data(user);

if (userRequest is ITitleSource)
ApplyTitleData(user);

...

return user;
}
The implementation for CreateUser can be made more dynamic but I think you
get the idea.

Good luck!

--
Saad Rehmani / Prodika / Dallas / TX / USA
I have several pages that will contain forms used for registering with
our website. These form won't always show the same information, as
their primary purposes are different, but part of the processing will
be the registration.

I'd like to have just one method for the entire site that handles the
creation of new account, referenced by all these forms.

So, assuming that form 'a' contains 8 fields required for
registration, form 'b' contains the min of 4, form 'c' contains 7 and
form 'd' has all 11, how would you create the method and then use it?

I'm new to C#, so bear with me. I've heard of overloading, but I think
I'd basically need 4 copies of the same method, which seems somewhat
over the top. I wondered about putting the form fields into an object
of some kind and then passing that object to the registration method.
Would that work?

What do you think would be the best way to get varying ammount of data
into a single method? Any examples and/or tutorial sites would be
greatly appreciated.

Thanks

Kevin

Sep 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
5
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
2
by: Nick | last post by:
Can someone please tell me how to access elements from a multiple selection list? From what ive read on other posts, this is correct. I keep getting an "Undefined variable" error though... Form...
2
by: Alexander Ross | last post by:
I have a variable ($x) that can have 50 different (string) values. I want to check for 7 of those values and do something based on it ... as I see it I have 2 options: 1) if (($x=="one") ||...
0
by: Dan Foley | last post by:
This script runs fine, but I'd like to know why it's so slow.. Thanks for any help out there on how i can make it faster (it might take up to 5 min to write these 3 export files whith 15 records...
5
by: Lee Redeem | last post by:
Hi there I've created abd uploaded this basic PHP script: <html> <head> <title>PHP Test</title> </head> <body> <H1 align="center">
5
by: christopher vogt | last post by:
Hi, i'm wondering if there is something like $this-> to call a method inside another method of the same class without using the classname in front. I actually use class TEST { function...
4
by: Phil Powell | last post by:
create table if not exists nnet_produkt_varegruppe ( nnet_produkt_varegruppe_id int not null auto_increment, primary key(nnet_produkt_varegruppe_id), nnet_produkt_varegruppe_navn varchar(255) not...
4
by: Adams-Blake Co. | last post by:
What technique do you folks use to keep your passwords and user names out of the phpMyAdmin config.inc file. Thanks, Al
2
by: Acorn Tutors | last post by:
Hi folks, what I would like to do is to store the name of a link, such as link1.php in a field, lets say the field is called Favoritelinks, in a database as a bit of text. Then, on a logged in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.