Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Post Data
Hi All,
I am trying to post data to a web page control but may be missing some important call.
 
Exact requirement:
1) Open an url
2) sign in to the application
3) Click a link to desired page or directly use the next page url to get the HTML webresponse.
 
Till here everything is fine
 
4) Now i need to put some data in 2 available textbox items available in the web response and click a button to let the page data posted to site and database and get the redirected URL
 
I am stuck in the 4th point.
 
Can anyone help
Thanks in advance
 
note its a C# console application i m using to create this test suit.
Posted 13-Dec-12 1:55am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I had a similar issue with a screenscraper program, and solved it with the following code:
HtmlElement element = Document.All["username"];
element.SetAttribute("value", myLogon);
element = Document.All["password"];
element.SetAttribute("value", myPassword);
element = Document.All["commit"];
element.InvokeMember("click");
The textboxes are named username and password in the DOM of the web page, and the action button is labelled commit. You just need to look into the HTML source to find the names of the elements that you wish to alter or otherwise manipulate.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 458
1 OriginalGriff 384
2 George Jonsson 233
3 Animesh Datta 130
4 Shemeemsha RA 128
0 OriginalGriff 6,179
1 Sergey Alexandrovich Kryukov 5,616
2 CPallini 4,770
3 George Jonsson 3,400
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 13 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100