Say we have a WebKitBrowser control and we set the DocumentText as such...
wkb.DocumentText = @"
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>
<head></head>
<body>
<form>
<input type='text' id='test' name='smith'><br>
</form>
</body>
</html>
";
If I was to then fetch the user input in that input field via C#, what is the proper method?
If I predefine the value attribute in the HTML, like...
<input type='text' id='test' name='smith' value='freedom'>
Then MessageBox.Show(wkb.Document.GetElementById("test").getAttribute("value")); accurately displays "freedom". However, if value is not defined, the result is always blank (I'm assuming it's null and not just empty).
This makes sense to me but I would be fetching user input, not predefined values. I suppose one could save the entire document to a string and parse it but it was much more simple in the standard IE browser control with the element.value route. What are my delicious options?
You can't read form values in C# client side. You have to post (AJAX or full postback) the form back to read the values in C#. If you want to see if a value has changed, you can use jQuery's
.on('blur' ...to capture the changed value and do an AJAX post back to the server.