I need to extract multiple text/dropdown list fields from an asp.net form and format appropriately ready for sending to recipient via email.
What’s the best way of reading those fields without having to hard code each item such as:
item1 = InputField1.Text; item2 = InputField2.Text;
I will have about 10 or 20 items on the same input form.
@Chris has given you the basic idea — copy out of the Request.Form collection. I would suggest that to make it easier, you give the inputs names that you can easily detect from the other fields on the page, some of which may be placed there for you by the framework. Perhaps use a naming scheme like ‘Email.FirstName’, ‘Email.LastName’, ‘Email.Address’, then you can do:
Note: if the page uses a MasterPage your check will need to take the name mangling by the framework into account.