How to find a number within an HTML list

0

I'm trying to find the number that the person wrote in the box in the document.getElementByID on the site, however I do not know how to do it in C #, or tried at least:

private void btnvalidar_Click(object sender, EventArgs e)
        {
            if (webrequestNumero.Document.GetElementById("Numero").InnerText.IndexOf(txtNumero.Text) == -1)
            {
                MessageBox.Show("O número está na lista");
            }
            else
            {
                MessageBox.Show("O número não está na lista");
            }
        }

Could anyone explain what's wrong with the code?

    
asked by anonymous 28.05.2018 / 05:12

1 answer

0

Please, would you have an example of the page source?

There are several ways for you to identify whether the text is on the site or not.

The box is inside some tag, an example TD or TR if you are, type this code below!

  

foreach (HtmlElement Html in WebBrowser.Document.Body.GetElementsByTagName ("tr"))               {                   MessageBox.Show (Html2.InnerText);               }

When doing this function C # will show you a msgbox informing the contents of the tag, so if you want you can do an If to identify if the value of the box corresponds to what you are looking for.

or better if the box is in an input with the ID or name you can do this another way

  

string = WebBrowser.Documento.GetelementByID ("BoxDoConteudo"). innertext;

Atte!

    
01.06.2018 / 17:04