[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

switch sites

Posted on 2006-05-10
6
Medium Priority
?
162 Views
Last Modified: 2010-04-23
hello,
I have this code in my app but what I want is something that switches to other site meaning that If I go to this site

WebBrowser1.Navigate(New System.Uri(" domain .com/inbox.asp"))

but if the site has this in it <input type="text" name="db_name" size="20" />
switches to

WebBrowser1.Navigate(New System.Uri(" domain .com/home.asp"))

how can I do this?
0
Comment
Question by:aplelois
  • 3
  • 3
6 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 16647035
Something like:

        Dim sSearchString As String = "<input type=""text"" name=""db_name"" size=""20"" />"

        WebBrowser1.Navigate(New System.Uri("http://domain.com/inbox.asp"))

        While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While

        If WebBrowser1.Document.Body.InnerHtml.Contains(sSearchString) Then
            WebBrowser1.Navigate(New System.Uri("http://domain.com/home.asp"))
        End If

?
0
 

Author Comment

by:aplelois
ID: 16647139
how can I add something at the end like this ??

WebBrowser1.Navigate(New System.Uri("http://domain.com/home.asp"))

      While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
            WebBrowser1.Document.DomDocument.Forms("Login").All("email").Value = "email at domain.com"
            WebBrowser1.Document.DomDocument.Forms("Login").All("pass").Value = "password"
        End While
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16647148
Just do it after the while loop. The While loop essentially halts execution of the code until the page has finished loading.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:aplelois
ID: 16647177
I mean when the person goes to home is where this goes
WebBrowser1.Document.DomDocument.Forms("Login").All("email").Value = "email at domain.com"
WebBrowser1.Document.DomDocument.Forms("Login").All("pass").Value = "password"
not in inbox.asp
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16647188
Oh, ok. In that case you need to add a second While loop to pause until Home.asp has finished loading, then you can set the values:

        Dim sSearchString As String = "<input type=""text"" name=""db_name"" size=""20"" />"

        WebBrowser1.Navigate(New System.Uri("http://domain.com/inbox.asp"))

        While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While

        If WebBrowser1.Document.Body.InnerHtml.Contains(sSearchString) Then
            WebBrowser1.Navigate(New System.Uri("http://domain.com/home.asp"))

            While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
                Application.DoEvents()
            End While

            WebBrowser1.Document.DomDocument.Forms("Login").All("email").Value = "email at domain.com"
            WebBrowser1.Document.DomDocument.Forms("Login").All("pass").Value = "password"

        End If
0
 

Author Comment

by:aplelois
ID: 16647205
thank you so much!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question