Forms collection in ASP.NET

Discussion in 'ASP .Net' started by Roshawn Dawson, Sep 21, 2005.

  1. Hi,

    This may seem like a trivial question, but I haven't been able to get this to work. Here goes...

    I have an .aspx page that is rendered using an xml file and an xsl file. The xsl file renders an
    html form and a number of controls on the page, in addition to transforming the xml file. (It goes
    without saying that neither the html form nor the other controls are server controls.) Everything is
    rendered as I desire.

    But using the form in code behind is my problem. When I try to access the form using the Request
    object, I get nothing. The form and all of the controls that it contains have their needed
    attributes set (name, id, value, etc.). I, however, can't access any of the form's controls using
    the Request.Forms collection.

    Considering the fact that I'm using an xsl file to render the html to the page, is this the reason
    that I can't access the controls in the form's collection? Must I create the html without the xsl
    file in order to get this to work?

    Thanks,
    Roshawn
    Roshawn Dawson, Sep 21, 2005
    #1
    1. Advertising

  2. Are you just using the "good ole" Request.Form["inputname"] method to get
    your values? If so, do your inputs have NAMES in the html? (Do a
    view-source.) Also, you're using method=POST in your form, not method=GET,
    right?

    Ray at home

    "Roshawn Dawson" <> wrote in message
    news:enCZ$...
    > Hi,
    >
    > This may seem like a trivial question, but I haven't been able to get this
    > to work. Here goes...
    >
    > I have an .aspx page that is rendered using an xml file and an xsl file.
    > The xsl file renders an html form and a number of controls on the page, in
    > addition to transforming the xml file. (It goes without saying that
    > neither the html form nor the other controls are server controls.)
    > Everything is rendered as I desire.
    >
    > But using the form in code behind is my problem. When I try to access the
    > form using the Request object, I get nothing. The form and all of the
    > controls that it contains have their needed attributes set (name, id,
    > value, etc.). I, however, can't access any of the form's controls using
    > the Request.Forms collection.
    >
    > Considering the fact that I'm using an xsl file to render the html to the
    > page, is this the reason that I can't access the controls in the form's
    > collection? Must I create the html without the xsl file in order to get
    > this to work?
    >
    > Thanks,
    > Roshawn
    Ray Costanzo [MVP], Sep 21, 2005
    #2
    1. Advertising

  3. Roshawn Dawson

    John Mardera Guest

    Post a sample html so we can see what can be wrong with it.


    "Roshawn Dawson" <> wrote in message
    news:enCZ$...
    > Hi,
    >
    > This may seem like a trivial question, but I haven't been able to get this
    > to work. Here goes...
    >
    > I have an .aspx page that is rendered using an xml file and an xsl file.
    > The xsl file renders an html form and a number of controls on the page, in
    > addition to transforming the xml file. (It goes without saying that
    > neither the html form nor the other controls are server controls.)
    > Everything is rendered as I desire.
    >
    > But using the form in code behind is my problem. When I try to access the
    > form using the Request object, I get nothing. The form and all of the
    > controls that it contains have their needed attributes set (name, id,
    > value, etc.). I, however, can't access any of the form's controls using
    > the Request.Forms collection.
    >
    > Considering the fact that I'm using an xsl file to render the html to the
    > page, is this the reason that I can't access the controls in the form's
    > collection? Must I create the html without the xsl file in order to get
    > this to work?
    >
    > Thanks,
    > Roshawn
    John Mardera, Sep 21, 2005
    #3
  4. Hi guys, thanks for your response.

    To answer Ray Costanzo's questions:

    1. I'm not using the "good ole" Request.Form(inputname) method to get my values. Instead I'm
    using the various properties of the Form collection (GetValues, GetKey, and Get).
    2. All input elements have names. However, the names are dynamic. They're based on some data that
    is contained within the xml file that's being transformed. Even the form itself has a name.
    Does it help to mention that the form contains a table that houses the the input elements in its
    rows? (To be specific, there is a checkbox that is used to check all other checkboxes in the
    form)
    3. Yes, the form's method is POST


    To John Mardera:

    Here's sample html for the form. As I mentioned above, the form contains a table that has input
    elements in its rows:

    <form id="Cart" method="post" action="ShoppingCart.aspx">
    <table id="items" cellpadding="0" cellspacing="0">
    <caption>Your Shopping Cart</caption>
    <thead>
    <tr>
    <th scope="col"><input type="checkbox" id="allItms" onclick="javascript:checkAll2(this)" /></th>
    <th scope="col">Title</th>
    <th scope="col">Price</th>
    <th scope="col">Quantity</th>
    <th scope="col">Total</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td><input type="checkbox" name="U175XG760VMHCS" /></td>
    <td><a href="Details.aspx?asin=159200878X">Maran Illustrated Mac OS X v.10.4 Tiger</a></td>
    <td class="price">$14.99</td>
    <td><input type="text" name="U175XG760VMHCS" maxlength="3" value="1" /></td>
    <td class="price">$14.99</td>
    </tr>
    <tr>
    <td><input type="checkbox" name="U1YOOYBVTVBOX6" /></td>
    <td><a href="Details.aspx?asin=0071436820">Investing in Rental Properties</a></td>
    <td class="price">$11.61</td>
    <td><input type="text" name="U1YOOYBVTVBOX6" maxlength="3" value="1" /></td>
    <td class="price">$11.61</td>
    </tr>
    <tr>
    <td><input type="checkbox" name="UGNFCT3Q1NT2M" /></td>
    <td><a href="Details.aspx?asin=0060765313">YOU: The Owner's Manual</a></td>
    <td class="price">$15.99</td>
    <td><input type="text" name="UGNFCT3Q1NT2M" maxlength="3" value="1" /></td>
    <td class="price">$15.99</td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
    <td id="subttl" colspan="5">Subtotal: $42.59</td>
    </tr>
    </tfoot>
    </table>
    <input type="submit" value="Update" />
    </form>

    HTH,
    Roshawn
    Roshawn Dawson, Sep 21, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dylan
    Replies:
    5
    Views:
    404
    Daniel T.
    Mar 22, 2005
  2. Pradeep
    Replies:
    2
    Views:
    664
    Patricia Shanahan
    Jan 24, 2007
  3. Øyvind Isaksen
    Replies:
    1
    Views:
    924
    Øyvind Isaksen
    May 18, 2007
  4. Hemant

    create collection of collection

    Hemant, Oct 22, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    402
    Gregory A. Beamer
    Oct 22, 2009
  5. Eric
    Replies:
    2
    Views:
    447
Loading...

Share This Page