Retrieving form data from an asp page

  • Thread starter Thread starter Robert Bravery
  • Start date Start date
R

Robert Bravery

HI all,

I retrive an response from an aspx page and store the resultant html into an
string object like:
string response = Encoding.UTF8.GetString(responseBytes);
this html page has form data in it, name value pairs. I need to get this
data and post it to another aspx page.

I know I can use webclient to post the formdata, but how do I get that into
a NameValueCollection so I can post it to another aspx page

Thanks

Robert
 
HI all,

I retrive an response from an aspx page and store the resultant html into an
string object like:
string response = Encoding.UTF8.GetString(responseBytes);
this html page has form data in it, name value pairs. I need to get this
data and post it to another aspx page.

I know I can use webclient to post the formdata, but how do I get that into
a NameValueCollection so I can post it to another aspx page

Thanks

Robert


if i have understood you correctly you have two pages
A,B
The above code is in A and responseBytes are from B.

1)you will have to parse the responsetring and find the input tages
using regex and add it to manually to the name value collection..i
dont have the regex..

2)if performance is not an issue you can get away from the parsing by
making B post to A in a javasript Onload (B) if a special
parameter is a passed..
so you will get the responsebytes by calling the page B.aspx?
special=1
and then exit.

That will make B call (post) A. you could make B post a special=1 to
A. so in your on load(Asp.net) event in a you could check special=1
and you willl get the forms values from B in a name value
collection..





But I think 1 is the way to go..
 
How are you getting the data from the HTML page?, you said is just
name/value pairs, does it have any HTML or just the list of
name=value&name2=value2&name3=value3?

If your getting it that way then you don't even need to decode it into a
string, you can just store it in a byte array and then pass it to the
UploadData method of the webclient.

If it's on ony other format, then just parse it into that format:
name1=value1&name2=value2.... (just like a URL querystring but without the
leading ?) , then encode it into binary and pass it to the WebClients
UploadData method as follows:
UploadData(http://tagetsite.com/targetpage.aspx, "POST", encodedBytes).

Hope that helps,
Fernando L Rodriguez, MCP
 
Thanks Guys,

I think I got that one working, now on to the next problem. HopefullI can
get some more answers from here

Robert
 
Back
Top