Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

Call a javascript function via vb.net in a webbrowser control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andre Rode - 20 Mar 2008 11:36 GMT
Hi!

Since you could help me fixing my last problem, I would like to demand
your help again.

In summary I'm writing an appliation that remotely controls a website.
It has to login (works), choose the right action (works) and put customer
data (works partially)in some fields.

Now some of these fields are being checked via javascript functions. For
example: is the account and the banking code correct?
This function is called in different ways, for example via the onblur
event of the input type in the html form.

How can I call these functions since a simple webbrowser.GetElementById
("inputid").SetAttribute("value",sAccountNo) won't call the onblur event?
I tried

Me.WebBrowser1.Document.GetElementById("customerForm").InvokeMember
("Blur")
or
Me.WebBrowser1.Document.GetElementById("customerForm").InvokeMember
("Change")
or

Me.WebBrowser1.Document.Forms.Item("customerForm").InvokeMember
(nameofthejsfunction)

but nothing works.

the call of the function is similar to this:

fieldChanged('bankAccountPaymentForm');;return;;A4J.AJAX.Submit
('customerForm:bankAccountPaymentForm:BankPaymentRegion','customerForm',e
vent,{'parameters':{'customerForm:bankAccountPaymentForm:
_id548':'customerForm:bankAccountPaymentForm:_id548'}
,'actionUrl':'/OEWeb/pages/newOrder.jsf'} )

the website is realisied by JavaServerFaces if this could have any
meaning.

Hope you can help me again
Greetings from Germany,
André
(O)enone - 20 Mar 2008 11:47 GMT
> How can I call these functions since a simple
> webbrowser.GetElementById
> ("inputid").SetAttribute("value",sAccountNo) won't call the onblur
> event? I tried

I have a WebBrowser control in one of my applications, and programmatically
call JavaScript functions using the following code:

\\\
browser.Document.Window.DomWindow.execscript("doSomething(parameters)",
"JavaScript")
///

This is probably different from calling within the context of a control
event, as I suspect things such as the "this" object may be referencing
different things, but perhaps this is enough to get you started..?

HTH,

Signature

(O)enone

GS - 20 Mar 2008 16:44 GMT
pardon me for jumping in,
is "Javascript" exactly the literal "JavaScript"?

when to use browser.document.invokescript(....) or something similar?

   args() as object
   '    ... setup the args objet
   browser.Document.InvokeScript(ScriptName, args)

> > How can I call these functions since a simple
> > webbrowser.GetElementById
[quoted text clipped - 14 lines]
>
> HTH,
(O)enone - 20 Mar 2008 18:12 GMT
> pardon me for jumping in,
> is "Javascript" exactly the literal "JavaScript"?

Yes, exactly that -- sorry, should have made that clearer.

> when to use browser.document.invokescript(....) or something similar?

I don't know about that one, someone else will have to help there...

Signature

(O)enone

Andre Rode - 31 Mar 2008 10:22 GMT
"\(O\)enone" <oenone@nowhere.com> wrote in news:fru624$lnh$1@aioe.org:

>> pardon me for jumping in,
>> is "Javascript" exactly the literal "JavaScript"?
[quoted text clipped - 4 lines]
>
> I don't know about that one, someone else will have to help there...

I just wanted to thank, the hint with
browser.Document.Window.DomWindow.execscript

worked perfectly

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.