Triggering TAB key to shift control by vb.net coding - vb.net

I am opening a web site in a vb.net 2008 webbrowser control. I want when I open the 3rd page of the web site then after the page is loaded , control focus programmatic-ly by Triggering TAB keypresses automatically by my code . Please tell me the solution to shift the focus control ?

I don't know if I have understood your question right, but you could try the following,
Keep track of whether you are on the third page in your web-browser control. If you are, you can execute a JavaScript function, which changes the focus of the text-fields.
Page.ClientScript.RegisteredStartUpScript(GetTypeOf(), "function_change_tabs", script, True)

Related

How to hide or cover a MS Access ActiveX Web Browser control?

I have a database in which users enter a value into Textbox1 on a form; the form also has an ActiveX Web Browser control (acxWebBrowser1), plus another blank Textbox2, and finally a command button. After the user enters text into Textbox1 and clicks the command button, the VBA code will navigate to a specific web page in acxWebBrowser1, enter the Textbox1 value into the web page form, and then obtain a result in the web page in acxWebBrowser1. The result is then grabbed by the VBA code and entered into Textbox2 on the database form.
What I need to be able to do is hide the ActiveX Web Browser control to (a) prevent the user from messing with the web page, and (b) to prevent the clutter and distraction of the ActiveX Web Browser since the VBA code does all the necessary interactions with the web page behind the scenes.
Problem is, I cannot get the acxWebBrowser1 to stay hidden behind a rectangle box control on the form because the browser automatically moves itself to the top of the stack of controls. If I reduce the size of the acxWebBrowser1 control to be very tiny, the web page does not function properly. If I make the web browser control not visible, then the code cannot grab the needed values. I cannot use a POST approach to avoid using the web browser. (I might be wrong about not being able to use POST--maybe someone can point me to how to do that if that is the way to go.)
How can I hide or put something on top of the web browser control?
Three hours later, it dawned on me how to accomplish hiding the ActiveX Web Browser but still get it to be accessible to the VBA code. Simple: Don't update the screen when running the code to access the ActiveX Web Browser and use the .Visible property to "show" the Browser Control when VBA needs to access it (but it won't be visible to the user if screen updating is off) and then hide the Browser Control when VBA is done accessing it.
Here's the code I used to accomplish that:
Application.Echo False 'turn off screen updating
Me.acxWebBrowser1.Visible = True 'make web browser control "visible" to VBA code
{do stuff, like: process web page}
Me.btnClickMe.SetFocus 'set focus on the button so we can hide the web browser control
Me.acxWebBrowser1.Visible = False 'make web browser invisible so user is not distracted
Application.Echo True 'turn screen updating back on
Me.Refresh 'refresh the screen; this is probably not necessary
Just be
absolutely sure to turn screen updating (echo) back on
You should send any error handling to code that sets Application.Echo True otherwise you will not be able to see or do anything if the code crashes after setting echo to False.

Auto Closing MessageBox controls

Is there a way to use VB.NET to close MessageBox controls created by JavaScript in VB.NET webbrowser?
I do not want to disable JavaScript in the webbrowser, just to close the MessageBox controls (like clicking their "X" button). I could not get help from search engines. Help appreciated.
Vb.net is serverside and rendered before javascript as the javascript is client side and rendered on browser. So there is not such way closing alert pop up via server side code.
Neither it is possible via jquery on client side

Copy / Paste functions not working on first load

I am having an issue with the Ctrl C / Ctrl V options working in a .net Control. This .net control has many textboxes and is called via COM Interop.
Program Flow:
VB6 application creates instance of .net control with the help of Interop Control Toolkit and VBControl Extender. A new tab is created in the code jock tab manager with the .net control as the body. The first time the control is loaded Control C / Control V operations do not work at all. If you close the tab then re-open the same exact control now Control C / Control V work correctly.
If you use the right click context menu to Copy / Paste then it does work.
I have checked Code Jock forumns and didn't find anything useful.
If you add a Key_Up event and capture the Copy that works fine. But we have many .net controls that would need to be changed and doing that for every text box seems like a bad hack. And I know it works without because it works on the second load.
do you open the tab exactly the same way when you open it the second time?
when you add a key_up event it does work on the first load? where did you add the key_up, on the tab or the .net control?
what exactly do you do in the key_up event? could you post the code?
my first guess was that it had something to do with the focus not being on the .net control or tab on first load, but that it has the focus on second load somehow ...

How to stop webbrowser control refreshing when server requests it

I have a webbrowser control that points at a webpage that holds some fields that change quickly. When these fields change the server seems to request that the webpage refreshes. This poses a problem if programatically interact with the webbroswer. Is there anyway to force the webbrowser to not refresh? No real code to show. since I'm hoping this is a one line property I can create/add.
Maybe you are looking for the WebBrowser.Stop() Method (MSDN)

CTRL+ TAB when webbrowser is in focus

I have a windows application with a tabcontrol. One of the tab of the tabcontrol has a webbrowser control.Now the issue that I am facing is when the focus is inside the webbrowser control, the normal Ctrl+Tab functionality of the tabcontrol is not working.I want the Ctrl+Tab to change the selected tab of tabcontrol even when the focus is inside webbrowser control in selected tab.How to achieve this ?
I have already tries overriding ProcessCmdKey.but it does not get hit when focus is inside webbrowser control.
I also tried registerhotkey method ,it works but it locks the Ctrl+Tab hotkey within my application & system doesn't respond to any other Ctrl+Tab presses outside my application when application is running, which is expected behaviour of registerhotkey.
Here is the code you need:
If WB.ContainsFocus Then
MsgBox("We have focus, disappearing...")
WB.Document.Body.RemoveFocus()
End If
Now, the question is, when to run that code. If you put it in the WebBrowser1_GotFocus event, you'll need to turn it on and off. Turn the code off if the user is interacting with the WB Control, and turn it back on when they are not and when you expect to be experiencing the problem you've mentioned.
Of course, you could add another line to ensure a particular control/tab/panel etc gets focus after you remove focus from the body. Also, here are 3 other SO questions that have answers which may help you, but these will take you in directions different to the direction I've provided, probably due to the fact that the questions are not identical to yours, but are similar enough to be useful (not listed in order of preference).
Prevent WebBrowser control from stealing focus?
Webbrowser steals focus
Focusing WebBrowser control in a C# application
UPDATE:
I just wanted to add, instead of the .Body.RemoveFocus() you could do this:
WB.Document.Body.Parent.RemoveFocus()
Which I prefer, since the .Document object didn't have an explicit .RemoveFocus method on the intellisense I was gettign in VS2012 RC. This is probably referring to the HTML tag (and not the .Document object) and since the html tag is the only parent to the body tag, it makes sense, and there is no "HTML" object directly available in the intellisense under object, since you can get it via other means, so it's just more convenient doing it this way.
Cheers, and let me know if you need more info on anything.