Passing request.form contents to a class

  • Thread starter Thread starter Stu
  • Start date Start date
S

Stu

Hi,

I have a class that is going to format all the fileds in a form post and
send them in an html email.

How do I pass the Request.Form contenst to a class? I know I can get the raw
data by converting it to a string, but this would mean processing the
string.....which is messy!

This is what I have got so far:

Private m_FormCol As Collection
Public WriteOnly Property formCol() As String
Set(ByVal Value As Collection)
m_FormCol = Value
End Set
End Property

I get the error Specified cast is not valid can't convert VB collection into
'System.Collections.Specialized.NameValueCollection'. If I pass it a
NameValueCollection'...how do I iterate through the items?

Thanks in Advance,

Stu
 
Any of your controls that have runat=server specified you just need to
declare in your base class, and you will be able to access them. So, if you
have:

<form runat="server" id="theForm">
<input type="text" runat="server" id="text">
</form>

Your code behind can have:

protected System.Web.UI.HtmlControls.HtmlForm theForm;
protected System.Web.UI.HtmlControls.HtmlInputText text;

With this declared at the class scope, you can then either iterate through
the child controls of the form or else directly fetch the items one by one
based on your explicit declaration, depending on what your needs are.

You have to think a bit differently with ASP.NET...
 
Back
Top