|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
HTML Forms Progamatically Via VB.NETI've been searching and searching and I can't seem to come up with a
decent enough search string at Google to get any useful information on what I'm looking for. I see scores of programs that pop open a web page and fill in form fields. Is this something that is easily done in VB.NET? I have a simple HTML form that I would like for some software to be able to fill in and submit automatically. Thanks!! Hi
I think we may need to use a webbrowser control to host html document. Here is a link for your reference. How to host a WebBrowser control in Visual Basic .NET to post form data (311294) http://support.microsoft.com/default.aspx?scid=KB;EN-US;311294 Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. Peter Huang [MSFT] wrote:
Show quoteHide quote > Hi I'm sorry, I wasn't very clear. This isn't a web based application - > > I think we may need to use a webbrowser control to host html document. > Here is a link for your reference. > How to host a WebBrowser control in Visual Basic .NET to post form data > (311294) > http://support.microsoft.com/default.aspx?scid=KB;EN-US;311294 > > Best regards, > > Peter Huang > Microsoft Online Partner Support > > Get Secure! - www.microsoft.com/security > This posting is provided "AS IS" with no warranties, and confers no rights. > this is a desktop app. I want to put a web browser control on a form and have the user click a "login" button, where the application will load up the page, fill in the user's username and password (which had been stored previously) and submit the form.. Mitchel,
That was what Peter was answering you, try this. Open a new windows application project In the toolbox rightclick and select add/Remove items In the customize toolbox select Com and in that Microsoft Webbrowser When that is in the toolbox drag it to your form Drag also a button to your form. Then this code and you have a mini Webbrowser. \\\ Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.AxWebBrowser1.Navigate2("www.google.com") End Sub /// I hope this helps a little bit? Cor Cor Ligthert wrote:
> \\\ Sure, sure, I can get the browser on the form. I'm just trying to > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click > Me.AxWebBrowser1.Navigate2("www.google.com") > End Sub > /// > > I hope this helps a little bit? > manipulate form fields on what ever page the browser happens to be sitting at (using the google example, I'd want to have a user click a button in my application and the browser open google, fill in the search field automatically *and* submit the form). I'll go re-read the link Peter posted. Perhaps I just didn't understand what I was reading. Thanks! Hi
I think Google will use HTTP GET method but no the POST method to collection data. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim cParamName As String Dim cSearchString As String cParamName = "q=" cSearchString = "Food" AxWebBrowser1.Navigate2("http://www.google.com/search?" & cParamName & cSearchString) End Sub The code above will seach the Food in the google. Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. Peter,
That is easy to see. http://www.google.com/search?hl=en&q=Peter+Huang&btnG=Google+Search Problem with the Post is that you cannot set hyperlinks, probably is it used on MSDN with some pages (it can also be just JavaScript), what is really annoying because that you cannot set a shortcut to it or copy the link. Maybe can you make once an internal note about that. Thanks in advance. Cor Cor Ligthert wrote:
Show quoteHide quote > Peter, All excellent information! Thank you both very much for taking the time > > That is easy to see. > http://www.google.com/search?hl=en&q=Peter+Huang&btnG=Google+Search > > Problem with the Post is that you cannot set hyperlinks, probably is it used > on MSDN with some pages (it can also be just JavaScript), what is really > annoying because that you cannot set a shortcut to it or copy the link. > > Maybe can you make once an internal note about that. > > Thanks in advance. > > Cor > > to help out! However, what I'm trying to do is actually *interact* with the web page the user goes to, rather than POSTing data to a CGI. The simplest example I can think of is when IE remembers a password on a web page for you. They actually fill in the form field and (sometimes) wait for you to click the "go" button. That is what I need to do - actually fill out the form on the web page, no go straight to the POST/GET. Thanks again! Mitchell,
I think that I knew where you was after, however I never give an answer on those questions because I find it so dangerous to do what you probably are after. One change in the design of the webpage can cost millions when it is a decimal shift. For this is in my opinion the webservice invented. Just my thought, Cor Cor Ligthert wrote:
Show quoteHide quote > Mitchell, I realize the potential dangers of doing what I want to do and will be > > I think that I knew where you was after, however I never give an answer on > those questions because I find it so dangerous to do what you probably are > after. One change in the design of the webpage can cost millions when it is > a decimal shift. > > For this is in my opinion the webservice invented. > > Just my thought, > > Cor > > keeping them in mind as I develop this software. I own and run both the web page/server this will be used with and the desktop software that will do it. A web service isn't possible for this situation, but I do appreciate you suggesting it. If you don't want to tell me what you know for fear that it will be used for malicious purposes I suppose I'll understand, but that isn't the case. Drop me a private email (mitch@ ksoftware.net) if you would like to avoid having the answer on a news group. I would *really* appreciate the help here. Thanks! Hi
If so I think you may try to take a look at the code below. Please a reference to mshtml .NET library. Private doc As mshtml.HTMLDocument Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click doc = Me.AxWebBrowser1.Document 'Get htmldocument Dim inputbox As mshtml.HTMLInputTextElement = doc.getElementsByName("q").item(, 0) 'get inputbox ref inputbox.value = "Food" 'Input value Dim submitButton As mshtml.HTMLInputButtonElement = doc.getElementsByName("btnG").item(, 0) 'get submit button ref submitButton.click() 'click the button End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load AxWebBrowser1.Navigate("http://www.google.com/") End Sub Best regards, Peter Huang Microsoft Online Partner Support Get Secure! - www.microsoft.com/security This posting is provided "AS IS" with no warranties, and confers no rights. Mitchell,
> I realize the potential dangers of doing what I want to do and will be Are you sure that a webservice not is possible in this situation. Everywhere > keeping them in mind as I develop this software. I own and run both the > web page/server this will be used with and the desktop software that will > do it. A web service isn't possible for this situation, but I do > appreciate you suggesting it. > where is a Windows NT that can have ASPNET it is even very simple to use. Here one of the in my opinion best Microsoft walkthroughs how to do that. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vbwlkCreatingDistributedWebApplicationWalkthrough.asp Maybe it gives a different point of view to your problem. On the other hand can you use the sample from Peter in my opinion. Although you can as well look what the HTTPwebrequest and HTTPwebrespond can do for you. (I never wrote that sent back part). This is the way to get the page as a string \\\\ Module main Public Sub main() Dim myReg As Net.HttpWebRequest = _ DirectCast(Net.WebRequest.Create("http://www.google.com"), _ Net.HttpWebRequest) Dim myResp As Net.HttpWebResponse = _ DirectCast(myReg.GetResponse(), Net.HttpWebResponse) Dim myStream As IO.Stream = myResp.GetResponseStream() Dim myreader As New IO.StreamReader(myStream) Dim mystring As String = myreader.ReadToEnd() myResp.Close() End Sub End Module /// I hope this helps anyway something. Cor Cor Ligthert wrote:
> Mitchell, Absolutely positive, Cor, but thanks again. I think I have it worked out > > >>I realize the potential dangers of doing what I want to do and will be >>keeping them in mind as I develop this software. I own and run both the >>web page/server this will be used with and the desktop software that will >>do it. A web service isn't possible for this situation, but I do >>appreciate you suggesting it. >> > > Are you sure that a webservice not is possible in this situation. now. Peter posted some information on exactly what I was trying to do! |
|||||||||||||||||||||||