Addi Khan
Addi Khan

Reputation: 77

how to winform texboxt Text transfer value web page textbox

I have textbox1, I want to transfer textbox1.Text into webbrowser1 web page textbox, how to do this?

I have below code, but webpage text box selected index change event not fired. How to do this?

private void button2_Click(object sender, EventArgs e)
{
    HtmlDocument doc = webBrowser1.Document;
    HtmlElement HTMLControl2 = doc.GetElementById("flightno-filter");
    //HTMLControl.Style = "'display: none;'";
    if (HTMLControl2 != null)
    {
        // HTMLControl2.Style = "display: none";
        HTMLControl2.InnerText = textBox1.Text;
    }
}

Please see below image

enter image description here

Upvotes: 1

Views: 419

Answers (1)

NoName
NoName

Reputation: 8025

You're trying to input text to webpage then make make the webbrowser raise the change/input event of the input box? You have to invoke "onChange" event or some other event.

Bellow I make WebBrowser raise keydown event, use SendKey:

private void button2_Click(object sender, EventArgs e)
{
    HtmlDocument doc = webBrowser1.Document;
    HtmlElement HTMLControl2 = doc.GetElementById("flightno-filter");
    //HTMLControl.Style = "'display: none;'";
    if (HTMLControl2 != null)
    {
        // HTMLControl2.Style = "display: none";
        HTMLControl2.InnerText = textBox1.Text;

        HTMLControl2.Focus();              // Set focus to input box
        SendKeys.SendWait("{Right}");      // Send "Right" key
        textBox1.Focus();                  // Give focus back for one of WinForms control

    }
}

Upvotes: 1

Related Questions