Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i have an experiment i'm working on and i would like to know if anyone has any suggestions on how i can accomplish this.

 

i have a windows form with a com web browser component inside of it. the web page loaded in the web browser component has 4 radio buttons and a submit button.

 

i want to make 4 windows buttons, that correspond with the 4 radio buttons in the web page. when any 1 button is pressed, it targets and selects the radio button on the web page.

 

then i have a 5th button that i would like to target the submit button.

 

the web page could exist inside the program as i've explained, or outside the program in another browser, .. i just want to make an external control which can interact with the web page.

  • *Experts*
Posted

I know you can interact with the WebBrowser control. There was a "trick" posted here a few months ago (maybe 6-12 months ago even). I know divil was involved in the thread, so you may try searching some old posts, especially using the name of the control (axwebbrowser or whatever it is).

 

The idea was to get a .NET object that represents the Document object of the current page (I think). You could then interact with the page, receiving events and setting properties - at least, that's what I vaguely remember about the topic.

 

Vague? Ah well, it's Saturday and I've 40 more hours of work to do in 2.5 days :)

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

thank you. this helps me ask my question better.

 

i need to target an html form field inside the browser control from the windows app.

 

this is code i saw in vb that would do it:

AxWebBrowser1.Document.forms(0).All("UserAccount").value = "username"

however, i don't get any elements after the 'Document' property.

 

axWebBroser1.Document. <-- there is no forms or anything else.

 

according to that vb example, then this should work in c#

axWebBrowser1.Document.forms[0].All["username"].value = "test";

any ideas on how i can accomplish this?

  • *Experts*
Posted

Here are two threads that may work for you (sorry I didn't have these last night - too late for me to do anything helpful).

 

http://xtremedotnettalk.com/showthread.php?t=69218&highlight=browser+event

http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69047

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
thank you. this helps me ask my question better.

 

i need to target an html form field inside the browser control from the windows app.

 

this is code i saw in vb that would do it:

AxWebBrowser1.Document.forms(0).All("UserAccount").value = "username"

however, i don't get any elements after the 'Document' property.

 

axWebBroser1.Document. <-- there is no forms or anything else.

 

according to that vb example, then this should work in c#

axWebBrowser1.Document.forms[0].All["username"].value = "test";

any ideas on how i can accomplish this?

The vb works because it uses late-binding, the C# you will have to cast everything prior, it does not use late binding...that's why you don't see anything. I did something similiar once at an old job... they used the most horrible time-sheet web-based programs... looked like it was made my a 12 year old... had more pointless script in it then you could believe... I mean think about it...43 pages of code this thing had just to enter the time you worked...but I digress... I prefer C# myself, but in this instance I made a class that did the interacting in VB...compiled it as a DLL and then referenced it in my C# forms based project.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...