Here's a simple one

  • Thread starter Thread starter Tomas Vera
  • Start date Start date
T

Tomas Vera

Hello All,
I've come across something that's probably simple, but I can't seem to figure
out (probably 'cause it's Monday.. yeah, That's it).

Anyway, how do I receive form information from a standard HTML or ASP page into
my ASPX page?

I assumed that Request.Form would hold the form info from the calling form. But
the form is always empty. This being the case, does the Request.Form member
contain "this" Form property? What property contains the referring form?

Examples

HTML file form code:
<form action="test.aspx" method="post">
<p>Name: <input type="text" name="username"></p>
<p>Email: <Input type="text" name="userEmail"></p>
<p><Input type="Submit" Value="Send it"></p>
</form>


TEST.ASPX.CS code snippet (Request.Form.Count is always zero):
private void ParseFormElements()
{
int i;
i =
for (i=0; i < Request.Form.Count; i++)
{
Response.Write("<p>" + Request.Form.ToString() + "</p>");
}

}
 
OK. That works. When going back over the code, I see now that I used an
"id='xxx'" to identify the <Input> control, but I did not use a "name='xxx'"
parameter. (That's what I get for re-typing in the newsgroup post by hand - my
bad code never got published!). Once I included the "name='xxx'" parameter, it
started showing up.

Thanks for the help.

-tomas


You can use 'Request["itemid"]' or 'Request.Params["item"]'.

-Darrin


Tomas Vera said:
Hello All,
I've come across something that's probably simple, but I can't seem to figure
out (probably 'cause it's Monday.. yeah, That's it).

Anyway, how do I receive form information from a standard HTML or ASP page into
my ASPX page?

I assumed that Request.Form would hold the form info from the calling form. But
the form is always empty. This being the case, does the Request.Form member
contain "this" Form property? What property contains the referring form?

Examples

HTML file form code:
<form action="test.aspx" method="post">
<p>Name: <input type="text" name="username"></p>
<p>Email: <Input type="text" name="userEmail"></p>
<p><Input type="Submit" Value="Send it"></p>
</form>


TEST.ASPX.CS code snippet (Request.Form.Count is always zero):
private void ParseFormElements()
{
int i;
i =
for (i=0; i < Request.Form.Count; i++)
{
Response.Write("<p>" + Request.Form.ToString() + "</p>");
}

}

 
Back
Top