HowTo: get request.form[i].name

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

  1. #1

    Default HowTo: get request.form[i].name

    Hello,

    HowTo: catch name/value pairs from request.form?

    My viewstate shows:
    "__VIEWSTATE=..&111=5.."
    I want to get this pairs of IDs/names [111] and values [5].
    But because the DropDownList ist dynamically created I don't know the
    name/ID of the created list. I can parse the viewState string to get the
    related name/value pairs, but I think there will be a more simple way
    provided by the request-object??

    wkr: Wilhelm Pieper


    Wilhelm Pieper Guest

  2. Similar Questions and Discussions

    1. request: 'HOWTO migrate IIS6.0 web services to ASP 2.0'
      CONTENTS summary setup error messages compensation attempts comment SUMMARY I have an IIS6.0 server which has recently been upgraded to ASP...
    2. Checkbox Set To OFF Not In Request.Form
      When using checkboxes on a form, if you uncheck them, the unchecked name/value pair in the Request.Form collection doesn't show up. It only shows...
    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. Cannot use Request.Form
      Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath....
    5. 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...
  3. #2

    Default Re: HowTo: get request.form[i].name

    Hi,

    I don’t know how you get the data from __viewstate field. This data is
    handling by the LosFormatter class. This class serializes the values of
    the controls into string presentation. The data format in the
    __viewstate isn’t in key=value format.

    Anyway you can get data from the Form Collection:
    string x = Request.form["myTextControl"];

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: HowTo: get request.form[i].name


    "Natty Gur" <natty@dao2com.com> schrieb im Newsbeitrag
    news:ehYVmL5QDHA.3144@tk2msftngp13.phx.gbl...

    > I don't know how you get the data from __viewstate field. ..
    Debugger :-)
    >
    > Anyway you can get data from the Form Collection:
    > string x = Request.form["myTextControl"];
    But I don't know the name "myTextControl".
    When getting the request.forms string I loop through this string and get
    the values I'm looking for but not the names related to this items:
    for (int i=0;i<Request.Form.Count;i++)

    Double dTmp = Convert.ToDouble(Request.Form[i].ToString());


    if (dTmp > 0) ..



    Wilhelm Pieper Guest

  5. #4

    Default Re: HowTo: get request.form[i].name

    OK,

    1)using debugger nice :-).

    2)What you really after? viewstate will return the last state of the
    control on the server while Form collection holds the values that sends
    from the client.

    Any way if you want you can:
    1) Use the LosFormatter class to get the cached data from the
    __viewstate field.
    2) Loop through the form elements (as you already did) to get the data
    Send from the client
    3) Loop through the WebForm controls to get their current values (the
    cached data and the one that changed by the user).

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  6. #5

    Default Re: HowTo: get request.form[i].name

    Hello Natty,

    thanks to your reply.
    Because your solution looks a little bit more code I tried
    string[] strRequest = Request.Form.ToString().Split('&');

    This returns all pairs I'm interested in in an easy to parse array like:
    "112=5", "113=4" and so on.


    "Natty Gur" <natty@dao2com.com> schrieb im Newsbeitrag
    news:#eYojn5QDHA.2676@TK2MSFTNGP10.phx.gbl...
    ...
    > 1) Use the LosFormatter class to get the cached data from the
    > __viewstate field.
    Isn't this the same like Request.Form.ToString()??
    > 2) Loop through the form elements (as you already did) to get the data
    > Send from the client
    > 3) Loop through the WebForm controls to get their current values (the
    > cached data and the one that changed by the user).
    I could (probably) do, but I'm not shure with this because my controls are
    added on the fly.
    So they may be not part of the controls collection.

    wkr: Wilhelm Pieper


    Wilhelm Pieper Guest

  7. #6

    Default Re: HowTo: get request.form[i].name

    I think you have a fundimental misunderstanding of .Net

    you DON"T need access to viewstate. The value of your control is
    automatically restored in your application on post-back. You query it's
    value then.

    These three properties should give you what you want

    "DropDownControl.SelectedValue"
    "DropDownControl.SelectedIndex"
    "DropDownControl.SelectedItem"

    ..Net removes you from dealing with the behind the scene plumbing of the
    web - GONE are the days of splitting on "&" etc etc etc.
    (unless you are a PHP pup (doh!))


    "Wilhelm Pieper" <w_pieper@web.de> wrote in message
    news:eze#$H4QDHA.1024@TK2MSFTNGP12.phx.gbl...
    > Hello,
    >
    > HowTo: catch name/value pairs from request.form?
    >
    > My viewstate shows:
    > "__VIEWSTATE=..&111=5.."
    > I want to get this pairs of IDs/names [111] and values [5].
    > But because the DropDownList ist dynamically created I don't know the
    > name/ID of the created list. I can parse the viewState string to get the
    > related name/value pairs, but I think there will be a more simple way
    > provided by the request-object??
    >
    > wkr: Wilhelm Pieper
    >
    >

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