I want to read the text from input objects, like a basic textbox for a name, in an html document but without it having to be "post"ed.
here's an example of the html doc loaded into the browser
Notice there is no submit button on the form.
Someone would fill in their name and a line of their address then click a System.Windows.Forms.Button
Here is my code (which doesn't work as I expected it to)
foreach(HtmlElement elt in browser.Document.Forms)
{
foreach(HtmlElement ch in elt.GetElementsByTagName("INPUT"))
{
MessageBox.Show(ch.Name + " Text = " + ch.InnerText);}
}
I was expecting it would show the text that was typed in but I keep getting a blank return.
Any help would be great!
Thanks!
Sean Murphy
"All things great and small start at the same point, the first step."
Sean Murphy
"All things great and small start at the same point, the first step."
SeanPosted Jul 22, 2007, 1:42 PM
C#
public form1()
{
InitializeComponent();
// Make the form the scripting object
browser.ObjectForScripting = this;
// Display the html file file.html
browser.Navigate(Application.StartupPath + "\\file.html");
}
void Button1Click(object sender, EventArgs e)
{
foreach(HtmlElement elt in browser.Document.Forms)
{
foreach(HtmlElement child in elt.GetElementsByTagName("INPUT"))
{
browser.Document.InvokeScript("SendTypedText", new object[] { child.Name });
}
}
}
public void ShowText(string ibox_name, string ibox_value)
{
MessageBox.Show(ibox_name + " = " + ibox_value);
//Of course now you can do whatever you need to do with the data
}
//file.html code
Sean Murphy
"All things great and small start at the same point, the first step."