0

I'm on this page and I'm trying to get to page 2 and it seems they use JavaScript to load the pages.

If I open up the Console in Firefox and paste in

javascript:__doPostBack('ctl00$PlaceHolderMain$CICContract1$gvSSP','Page$2')

the second page is loaded.

I was wondering if there is a way to do this in C#, perhaps through the WebClient? I'm looking to loop through all the listed pages and the alternative using WebRequests was extremely unwieldy.

Edit: I don't have access to the internals or source code of the site. I'm writing a web crawler.

  • you can do the same thing using `__DoPostBack` in a JavaScript and point it to the event that you are wanting then from there issue a Redirect to `Page2.aspx` – MethodMan Nov 25 '14 at 17:31
  • @DJKRAZE: I'm not sure I follow. Could you elaborate? – John Smith Nov 25 '14 at 17:33
  • you can create a javascript in your `.aspx` page I will post an example in the answer for readability – MethodMan Nov 25 '14 at 17:34
  • Maybe http://stackoverflow.com/questions/172753/embedding-javascript-engine-into-net ? – Chris Nov 25 '14 at 17:57
  • @Chris: That just executes JavaScript code in C#. I need the code to be executed on the web page. – John Smith Nov 25 '14 at 18:09
  • if you do not understand the example that I have posted and now deleted then perhaps you need to edit the question and make your question more clearer if you need the code to be executed on the page then you can use either JavaScript events calling via the aspx page or you can use some ajax calls – MethodMan Nov 25 '14 at 18:30

1 Answers1

0

You can use RegisterStartupScript in you C# code.

Look at to this document http://www.webblogsforyou.com/how-to-call-javascript-function-from-code-behind-in-asp-net-c-vb-net/

developergg
  • 837
  • 1
  • 7
  • 12