Forms collection in ASP.NET

  • Thread starter Thread starter Roshawn Dawson
  • Start date Start date
R

Roshawn Dawson

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
 
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
 
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
 
Back
Top