Passing request.form contents to a class

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
 
C

Chris Jackson

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top