469,925 Members | 1,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,925 developers. It's quick & easy.

simulating/calling javascript functions programmatically

YR
Hello,

I am tasked to write an application for a travel agency, that should be able to get a price for airline tickets from airline's website. Generally, airlines don't provide any web services for this, so I am sort of forced to simulate all the clicks/list boxes selection that a regular user would make. Most of those buttons have a java script associated with them, so as soon as a button's clicked -- java script runs.

So, here is the question: what's the best way to implement a call to a javascript? Would I use ASP.NET platform, since it has these HttpRequest / Response objects? What would I put in my HttpRequest?

For instance, if a web page http://www.mysite.com/page.cgi has a java script that looks something like this:

function submit_SomeForm()
{
document.SomeForm.A.value = "A"
document.SomeForm.B.value = "B"
document.SomeForm.C.value = "C"

document.SomeForm.submit()
}

What would be a code snippet that would setup SomeForm document with all the values and submit it to the site?
Also, what tools would I use to see what the http string that goes from my browser to the site is like?

I understand that I am sort of asking for a lot but I appreciate any help -- I am a rookie at this and it's tough to ask the right question :)

I appreciate any help.

Sincerely,
YR
Nov 18 '05 #1
5 2957
Take a look at the WebRequest class which will allow you to do GET and
POST. For example, here is a sample doing a POST :
http://samples.gotdotnet.com/quickst...lientPOST.aspx

One of the first tools I would get for debugging would be something
like tcpTrace (see http://www.pocketsoap.com/tcptrace/). This easily
allows you to see all the traffic between yourself and a web site. You
can compare what your code is sending versus what the browser sends.
Even before debugging, it will show you a little bit about what
happens on the form.submit call.

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 21 Jan 2004 22:56:06 -0800, "YR"
<an*******@discussions.microsoft.com> wrote:
Hello,

I am tasked to write an application for a travel agency, that should be able to get a price for airline tickets from airline's website. Generally, airlines don't provide any web services for this, so I am sort of forced to simulate all the clicks/list boxes selection that a regular user would make. Most of those buttons have a java script associated with them, so as soon as a button's clicked -- java script runs.

So, here is the question: what's the best way to implement a call to a javascript? Would I use ASP.NET platform, since it has these HttpRequest / Response objects? What would I put in my HttpRequest?

For instance, if a web page http://www.mysite.com/page.cgi has a java script that looks something like this:

function submit_SomeForm()
{
document.SomeForm.A.value = "A"
document.SomeForm.B.value = "B"
document.SomeForm.C.value = "C"

document.SomeForm.submit()
}

What would be a code snippet that would setup SomeForm document with all the values and submit it to the site?
Also, what tools would I use to see what the http string that goes from my browser to the site is like?

I understand that I am sort of asking for a lot but I appreciate any help -- I am a rookie at this and it's tough to ask the right question :)

I appreciate any help.

Sincerely,
YR


Nov 18 '05 #2
Take a look at the WebRequest class which will allow you to do GET and
POST. For example, here is a sample doing a POST :
http://samples.gotdotnet.com/quickst...lientPOST.aspx

One of the first tools I would get for debugging would be something
like tcpTrace (see http://www.pocketsoap.com/tcptrace/). This easily
allows you to see all the traffic between yourself and a web site. You
can compare what your code is sending versus what the browser sends.
Even before debugging, it will show you a little bit about what
happens on the form.submit call.

HTH,

--
Scott
http://www.OdeToCode.com

On Wed, 21 Jan 2004 22:56:06 -0800, "YR"
<an*******@discussions.microsoft.com> wrote:
Hello,

I am tasked to write an application for a travel agency, that should be able to get a price for airline tickets from airline's website. Generally, airlines don't provide any web services for this, so I am sort of forced to simulate all the clicks/list boxes selection that a regular user would make. Most of those buttons have a java script associated with them, so as soon as a button's clicked -- java script runs.

So, here is the question: what's the best way to implement a call to a javascript? Would I use ASP.NET platform, since it has these HttpRequest / Response objects? What would I put in my HttpRequest?

For instance, if a web page http://www.mysite.com/page.cgi has a java script that looks something like this:

function submit_SomeForm()
{
document.SomeForm.A.value = "A"
document.SomeForm.B.value = "B"
document.SomeForm.C.value = "C"

document.SomeForm.submit()
}

What would be a code snippet that would setup SomeForm document with all the values and submit it to the site?
Also, what tools would I use to see what the http string that goes from my browser to the site is like?

I understand that I am sort of asking for a lot but I appreciate any help -- I am a rookie at this and it's tough to ask the right question :)

I appreciate any help.

Sincerely,
YR


Nov 18 '05 #3
I had a similar query (actually posted it just before yours) and found my
answer in the Page.RegisterClientScriptBlock method. It lets you add client
side Javascript to your page from within your server side ASP.NET code.

Regards,

Lachlan
Nov 18 '05 #4
YR
Thanks.

YR
Nov 18 '05 #5
YR
Thanks.

YR
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Dave Ekhaus | last post: by
7 posts views Thread by Julia Briggs | last post: by
7 posts views Thread by JCO | last post: by
1 post views Thread by Chris | last post: by
4 posts views Thread by Roger Withnell | last post: by
5 posts views Thread by Xu, Qian | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.