Forms collection in ASP.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roshawn Dawson

    #1

    Forms collection in ASP.NET

    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]

    #2
    Re: Forms collection in ASP.NET

    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" <udrago@bellsou th.net> wrote in message
    news:enCZ$AlvFH A.3548@tk2msftn gp13.phx.gbl...[color=blue]
    > 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[/color]


    Comment

    • John Mardera

      #3
      Re: Forms collection in ASP.NET


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


      "Roshawn Dawson" <udrago@bellsou th.net> wrote in message
      news:enCZ$AlvFH A.3548@tk2msftn gp13.phx.gbl...[color=blue]
      > 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[/color]


      Comment

      • Roshawn Dawson

        #4
        Re: Forms collection in ASP.NET

        Hi guys, thanks for your response.

        To answer Ray Costanzo's questions:

        1. I'm not using the "good ole" Request.Form(in putname) 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="Shoppin gCart.aspx">
        <table id="items" cellpadding="0" cellspacing="0" >
        <caption>Your Shopping Cart</caption>
        <thead>
        <tr>
        <th scope="col"><in put type="checkbox" id="allItms" onclick="javasc ript:checkAll2( this)" /></th>
        <th scope="col">Tit le</th>
        <th scope="col">Pri ce</th>
        <th scope="col">Qua ntity</th>
        <th scope="col">Tot al</th>
        </tr>
        </thead>
        <tbody>
        <tr>
        <td><input type="checkbox" name="U175XG760 VMHCS" /></td>
        <td><a href="Details.a spx?asin=159200 878X">Maran Illustrated Mac OS X v.10.4 Tiger</a></td>
        <td class="price">$ 14.99</td>
        <td><input type="text" name="U175XG760 VMHCS" maxlength="3" value="1" /></td>
        <td class="price">$ 14.99</td>
        </tr>
        <tr>
        <td><input type="checkbox" name="U1YOOYBVT VBOX6" /></td>
        <td><a href="Details.a spx?asin=007143 6820">Investing in Rental Properties</a></td>
        <td class="price">$ 11.61</td>
        <td><input type="text" name="U1YOOYBVT VBOX6" maxlength="3" value="1" /></td>
        <td class="price">$ 11.61</td>
        </tr>
        <tr>
        <td><input type="checkbox" name="UGNFCT3Q1 NT2M" /></td>
        <td><a href="Details.a spx?asin=006076 5313">YOU: The Owner's Manual</a></td>
        <td class="price">$ 15.99</td>
        <td><input type="text" name="UGNFCT3Q1 NT2M" maxlength="3" value="1" /></td>
        <td class="price">$ 15.99</td>
        </tr>
        </tbody>
        <tfoot>
        <tr>
        <td id="subttl" colspan="5">Sub total: $42.59</td>
        </tr>
        </tfoot>
        </table>
        <input type="submit" value="Update" />
        </form>

        HTH,
        Roshawn

        Comment

        Working...