My simple Web Form consists of several Input Controls and methods like: InsertRecord, UpdateRecord etc.
I want to decouple these tightly integrated methods. I want to know:
Where to keep Insert and Update methods?
If Insert method sets SqlParameter values, then how to send Input Control values to this method in a separate class. The method code is shown below. I want to write a method which automatically checks for nulls.
Is there any standard pattern that needs to be followed for a typical Web Form's code behind? Like Repository Pattern etc?
rpk2006
Member
631 Points
631 Posts
Which standard pattern to follow for a simple Web-Form's code-behind?
Jun 30, 2012 10:24 AM|LINK
My simple Web Form consists of several Input Controls and methods like: InsertRecord, UpdateRecord etc.
I want to decouple these tightly integrated methods. I want to know:
protected void InsertRecord() { cmdSaveOrUpdate.Parameters.Add(new SqlParameter("@record_locked", SqlDbType.VarChar)); cmdSaveOrUpdate.Parameters["@record_locked"].Value = ""; cmdSaveOrUpdate.Parameters.Add(new SqlParameter("@OfficeID", SqlDbType.Int)); cmdSaveOrUpdate.Parameters["@OfficeID"].Value = Session["LoggedOfficeID"].ToString(); }alvingeorge
Participant
925 Points
203 Posts
Re: Which standard pattern to follow for a simple Web-Form's code-behind?
Jun 30, 2012 11:47 AM|LINK
One approch could be
you can create this method in another class and add two paramterers, one Stored Proc Name string, collection of SqlParameter
BrockAllen
All-Star
28084 Points
4997 Posts
MVP
Re: Which standard pattern to follow for a simple Web-Form's code-behind?
Jun 30, 2012 01:14 PM|LINK
Your question reminds me of the ASP.NET MVP (model view presenter) pattern:
http://webformsmvp.com/
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/