473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Retrieving form data from an asp page

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

Jun 27 '08 #1
3 1792
On May 1, 11:35 am, "Robert Bravery" <m...@u.comwrote:
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..
Jun 27 '08 #2
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
"Robert Bravery" <me@u.comwrote in message
news:8E**********************************@microsof t.com...
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

Jun 27 '08 #3
Thanks Guys,

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

Robert

"Fernando Rodriguez, MCP" <fr********@mcp.microsoft.comwrote in message
news:Os**************@TK2MSFTNGP04.phx.gbl...
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
"Robert Bravery" <me@u.comwrote in message
news:8E**********************************@microsof t.com...
>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


---
avast! Antivirus: Inbound message clean.
Virus Database (VPS): 080501-0, 01/05/2008
Tested on: 02/05/2008 12:18:23 PM
avast! - copyright (c) 1988-2008 ALWIL Software.
http://www.avast.com
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Shipley | last post by:
I am trying to present a list of links on a page (Form) where each link opens a different picture gallery. I have the Form page which contains the links, a Gallery page, and several include files....
7
by: Sirplaya | last post by:
I am retrieving images that I stored in SQL Server on my web pages in C#. I have no problem with the images displaying, however, I am trying to wrap the image with an <A HREF ..." and each time I...
1
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
7
by: rfinch | last post by:
Very new to this but using the MS working with dynamics CRM 3.0 book to run web application to retrieve lead records from CRM 3.0. Have followed the book instructions on page 380-382. But am...
2
by: 4Ankit | last post by:
hello all, i am having some difficulty retrieving information from my form. I want to add content in my table but the content i want to add to the table is what the user inputs in my form. ...
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am using ASP.Net 2.0 and VB.Net (although C#is ok also). I want to create an object/method/function that will take a URL as an input parameter and then return all of the HTML in that page. I...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
1
by: fidgen | last post by:
Hiya, I'm trying to get a AJAX driven update to my list of news articles, so when users click the title of the news article, it pops up the article content in a thickbox overlay. Retrieving...
2
by: phpnewbie26 | last post by:
I currently have two drop down menus where the second one is populated from the first one. My second drop down menu should be able to do multiple selection. I have searched online and found out how...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.