Passing request.form contents to a class

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Passing request.form contents to a class

    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.NameValueCollectio n'. If I pass it a
    NameValueCollection'...how do I iterate through the items?

    Thanks in Advance,

    Stu



    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.507 / Virus Database: 304 - Release Date: 04/08/2003


    Stu Guest

  2. Similar Questions and Discussions

    1. Passing request to service
      http://www.dotnet247.com/247reference/msgs/14/70814.aspx "Chris" <Chris@discussions.microsoft.com> wrote in message...
    2. [PHP-DEV] help request: passing return value
      Hi internals. I'm newbie here and with php extensions. Working on php extension. It should give access to librep. I have very little...
    3. Confused about a REQUEST.FORM and a REQUEST.QUERYSTRING
      This is snipit of code, supplied by PayPal with explanation about what has to be done to access their back end. I am confused because they first...
    4. best way to get data: request.form, request.params, controlname.value
      Hi! I think I remember somewhere that using request.form was a bad idea (I can't say I remember why). So I'm wondering: What is the best way to...
    5. Passing contents of a flat file to an internal variable
      I want to do something like this inside a sproc: DECLARE @internalText VARCHAR(8000) SET @internalText="c:\myTestXML.XML" QUESTION: ...
  3. #2

    Default Re: Passing request.form contents to a class

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

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows XP
    Windows XP Associate Expert
    --
    "Stu" <stuart@ntpcl.uk.com> wrote in message
    news:uqcSYkAYDHA.2484@TK2MSFTNGP09.phx.gbl...
    > 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.NameValueCollectio n'. If I pass it a
    > NameValueCollection'...how do I iterate through the items?
    >
    > Thanks in Advance,
    >
    > Stu
    >
    >
    >
    > ---
    > Outgoing mail is certified Virus Free.
    > Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    > Version: 6.0.507 / Virus Database: 304 - Release Date: 04/08/2003
    >
    >

    Chris Jackson Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139