Monday, March 26, 2012

HTML Form value retrieval

Yes. If you use the action attribute, it works fine. Here's an example, from
this working page
http://www.pmaconference.com/specia...04/register.htm

<form name="form" onsubmit="return(sendReg())"
action="https://energycatalogue.acomhosting.com/orderform.aspx"
"Matt" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:F7ED5A87-B31F-4BA8-A0A2-CFC966462174@dotnet.itags.org.microsoft.com...
> I have an aspx page whose purpose is to read a customer-provided HTML
form, display it, and reads the values from it on a postback. I cannot seem
to read the values from Request.Form when this type of form is posted back.
All I am trying to do is loop through the items in Request.Form and store
their values for later use in the application. Neither the "form" tag nor
the control tags use the runat="server" attribute since this is a
customer-created form that we would like to be standard HTML to allow full
control of the form contents, and look and feel of the form. There will
only ever be one client-side form per rendering of the page. By adding the
runat="server" attribute to the form tag, I have been able to see only one
item in the Request, _VIEWSTATE. None of the other HTML controls will
appear in the collection. Is this type of thing possible?Thanks for the reply. Even with the action on the form, I the Request.Form.Count value is also zero when I do a postback. Obviously there's something wrong, probably very basic. Below is the form that I am testing with. I've tried with and without the METHOD and ACTION attributes

<form name="autos" method="post" action="http://cregosource/privateparty/formdata.aspx"><input type="checkbox" id="check" value="checkvalue"><br><input type="checkbox" id="check2" value="checkvalue2"><br><input type="text" id="text" value="333333"><textarea id="mytextarea">asdf</textarea><input type="radio" id="myradio" value="1"><input type="radio" id="myradio" value="2"><input type="radio" id="myradio" value="3"><select id="myselect" size="5"><option>1</option><option>2</option></select><select id="myselectmultiple" size="5" multiple><option value="1">one</option><option value="2">two</option><option value="3">three</option><option value="4">four</option><option value="5">five</option></select><br><br><input type="submit" value="Submit"></form

And here's the code in a codebehind page that I'm debugging

if (Request.Form.Count>0)

foreach (string strReq in Request.Form)

oTrans.KeyAddOrReplace(PrivateParty.TranState.Sect ionType.Form,strReq,Request[strReq])

oTrans.SaveState()

Even if I omit the Count test, there are no items in the Form. Does it pose a problem if I am using usercontrols on this page? I do not specifically call out any form tags in these controls. Any additional help is much appreciated!

No comments:

Post a Comment