• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 502
  • Last Modified:

go to next page

hello,
I would like to create soemthing so that when I click this button
WebBrowser1.Navigate(New System.Uri("http :// domain com"))

it goes to this page and then click on next >>
then next, next, etc...

<a href="javascript:back(1);"><< back </a>| <a href="javascript:next(3);">next >></a>

page3 has javascript:next(4);
page4 has javascript:next(5);
so on.. how can I do this ?
0
aplelois
Asked:
aplelois
  • 8
  • 7
1 Solution
 
wtconwayCommented:
Are you wanting to let a button on your form send these commands to the webbrowser control? Or are you just wanting the user to click the links in the webbrowser control and have it go to the next page?
0
 
apleloisAuthor Commented:
yes = Are you wanting to let a button on your form send these commands to the webbrowser control
0
 
wtconwayCommented:
I answered a similar question to this a while back. Check this post out:

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_21524297.html
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
apleloisAuthor Commented:
this is my javascript

        function next(pageNumber)
        {
            theForm.page.value = pageNumber;
              theForm.action = "search.php";
              theForm.submit();
              return true;
        }      
0
 
wtconwayCommented:
I haven't done this in a while. Let me do some testing and I'll get back to you.
0
 
wtconwayCommented:
Ok here's the VB.NET code I used. "web" is the name of my webbrowser control.

    Public currentPage As Integer = 1
    Public maxPage As Integer = 5

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        web.Navigate(Application.StartupPath & "\page1.htm")
    End Sub

    Private Sub CallJSNavigate()
        Dim doc As mshtml.HTMLDocumentClass = web.Document
        Dim btn As Object = doc.getElementById("btn")
        Dim hid As Object = doc.getElementById("pageNumber")
        hid.Value = currentPage
        btn.click()
        Dim js As mshtml.HTMLScriptElementClass = doc.scripts.item(Nothing, 0)

    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        If currentPage < maxPage Then
            currentPage += 1
        Else
            currentPage = 1
        End If
        CallJSNavigate()
    End Sub

    Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
        If currentPage > 1 Then
            currentPage -= 1
        Else
            currentPage = maxPage
        End If
        CallJSNavigate()
    End Sub

and here's my page:

<html>
<head>
<title>Page</title>
<script langauge="javascript">
      function nav(pg){
            var msg = "User wants to go to page " + pg;
            alert(msg);
            
      }
</script>
</head>
<body>
<input type="hidden" name="pageNumber" id="pageNumber" value=1>
<input type="button" name="btn" id="btn" value="Does not matter" style="display:none;" onClick="nav(document.getElementById('pageNumber').value)">
This is the page.
</body>
</html>

See if you can get that to work.
0
 
wtconwayCommented:
I'm about to leave the office for the evening. I'll check your responses in the morning.
0
 
apleloisAuthor Commented:
I get these two things

Error      1      Type 'mshtml.HTMLDocumentClass' is not defined.      
Error      2      Type 'mshtml.HTMLScriptElementClass' is not defined.
0
 
wtconwayCommented:
Do you have a webbrowser control in your application? That class should be added as a reference. If it is not then look here:

C:\WINDOWS\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll

I'm running XP Pro SP2 and that is where M$ installed that DLL for me. Perhaps it is there for you. If not, just search your drive for that DLL and add it as a reference in your app.
0
 
apleloisAuthor Commented:
done, now this

Error      1      Value of type 'System.Windows.Forms.HtmlDocument' cannot be converted to 'mshtml.HTMLDocumentClass'.

Dim doc As mshtml.HTMLDocumentClass = Web.Document

error = Web.Document
0
 
apleloisAuthor Commented:
I had to change it to -> WebBrowser1.Document.DomDocument
0
 
apleloisAuthor Commented:
ok i have a problem the html page doesnt have any type="button" it only has this
<a href="javascript:GotoPage(1);">1</a>
<a href="javascript:GotoPage(2);">2</a>
<a href="javascript:GotoPage(3);">3</a>
<a href="javascript:GotoPage(4);">4</a>
<a href="javascript:GotoPage(5);">5</a>
0
 
apleloisAuthor Commented:
got it thanks
0
 
wtconwayCommented:
So everything works now?
0
 
apleloisAuthor Commented:
yes
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now