dcsimg
Results 1 to 4 of 4

Thread: Pushing new information to a WebBrowser Control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    24

    Pushing new information to a WebBrowser Control

    Hi,

    So I am currently writing an application that takes in user criteria and searches through a webpage for links and then returns them. The application woks just fine if you only want to search once... I cannot figure out how to reset the attributes of the website I am linked to via WebBrowser Control. I set the textfields of the connected website when I click the search button by using
    Code:
    wbCraigsList.Document.GetElementById("query").SetAttribute("value", searchDescription)
    but then when i go to search again, the user's criteria is different but it doesn't change the WebBrowser control's attributes. For example, if i originally search "ford" in the description on my app and click search it fills in the craigslist search box with "ford" and searches. If I go to change "ford" to "chevy" on my app the WebBrowser control does not change the craigslist textfield and still searches ford.

    Code:
     'set the craigslist text fields to the user's criteria
        Private Sub setUserSearchCriteria(desc As String, min As String, max As String)
            wbCraigsList.Document.GetElementById("query").SetAttribute("value", desc)
            wbCraigsList.Document.All.GetElementsByName("minAsk")(0).SetAttribute("value", min)
            wbCraigsList.Document.All.GetElementsByName("maxAsk")(0).SetAttribute("value", max)
        End Sub
    
        Private Sub clearSearch()
            txtSearch.Text = Nothing
            txtMinPrice.Text = Nothing
            txtMaxPrice.Text = Nothing
        End Sub
    
        'Starts the search process through Craigslist
        Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
            Try
                Me.getUserSearchCriteria()
                MessageBox.Show("Search Description: " + searchDescription)
                wbCraigsList.Document.GetElementById("query").SetAttribute("value", searchDescription)
                wbCraigsList.Document.All.GetElementsByName("minAsk")(0).SetAttribute("value", searchMinPrice)
                wbCraigsList.Document.All.GetElementsByName("maxAsk")(0).SetAttribute("value", searchMaxPrice)
    
                wbCraigsList.Document.All("searchbtn").InvokeMember("click")
    
                numResults = wbCraigsList.Document.GetElementsByTagName("a").Count
    
                'create an elements collection to store the links of the search results
                Dim resultsCollection As HtmlElementCollection
                resultsCollection = wbCraigsList.Document.GetElementsByTagName("a")
    
                Results.Show()
    
                For i As Integer = 0 To numResults Step 1
                    Results.txtResults.AppendText("Test" + vbLf)
                Next
            Catch ex As Exception
                MessageBox.Show(ex.Message())
            End Try
    
            searchDescription = ""
        End Sub
    
        Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
            clearSearch()
        End Sub
    Please let me know if you need clarification on anything. Thanks, any help would be awesome!

  2. #2
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,313

    Re: Pushing new information to a WebBrowser Control

    Stop using a browser. It's a UI control. Look at the MSDN documentation for webclient class.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2013
    Posts
    24

    Re: Pushing new information to a WebBrowser Control

    I'll look into using that. Thank you

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,313

    Re: Pushing new information to a WebBrowser Control

    It helps if you post the url.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width