About the answering your question:
I have a namespace that is in the file: blahbase.cs, and inside there I have some subroutines.
I was planing on uniformity of the web form id names, so that the subroutine would "assume" the key name and do whatever the routine was designed to with the associating value.
That way I would be able, when adding or updating records, to send the data form fields from many different pages without have to declare all the variables and send each form field data.
For example:
public void updateContactAddressRecord(string idcontact, string line1address, string line2address, ...<all the rest of the fields>)
{
...update the records...
}
[This is not redundant, however this is where I'm duplicating code]
in webform: form1.aspx.cs
updateContactAddressRecord(hidContactID, txtLine1Address.Text.ToString(), txtLine2Address.Text.ToString(), ...);
in webform: form2.aspx.cs [in some other area, I have to change the address record]
updateContactAddressRecord(hidContactID, txtLine1Address.Text.ToString(), txtLine2Address.Text.ToString(), ...);
and maybe some other page does it again...so I'm up to three places.
If all the form fields are uniform in thier names across the diffent pages, then it would be easier to write it this way:
public void updateContactAddressRecord(string idcontact, <cast unknown to me> formcollection)
{
...pull the name and value pairs out of the formcollection array, and then manipulate data...
}
then the calls are used like this:
updateContactRecord(hdnContactID, Request.Form.<unknown to me>);
less code writing, but more important to me, is the ease of changing my data structure if needed: I can add a web form element (with a uniformed name such as txtCountry) to all the pages that need to accept the data, and then modifiy in only one place the actual code that is used to manipulate the data, since the entire form collection is being sent to the location that does the data manipulation....
does this make sense? Is my fundemental understand of code normalization putting me in a box I'm going to want to get out of later as the application gets more sophisticated?
Brian
PS: no spell check, sorry 4'em
Brian Sausser, MCP
(858) 229-6129
|