C# Webbrowser and form questions
-
Ok here's the skinny: I want to allow users to create their own forms and they are familiar with html, hence they will write them in html. It is basically data entry, but in varying formats. I want to be access the information they put in the various input boxes through my windows application. Is there a way to query the forms they create. In other words, can I have their forms in an html browser on one panel and have the submit button on another panel where the code would reside and I can see their entered data? I appreciate any and all help!
Thanks! Sean Murphy "All things great and small start at the same point, the first step."
-
Ok here's the skinny: I want to allow users to create their own forms and they are familiar with html, hence they will write them in html. It is basically data entry, but in varying formats. I want to be access the information they put in the various input boxes through my windows application. Is there a way to query the forms they create. In other words, can I have their forms in an html browser on one panel and have the submit button on another panel where the code would reside and I can see their entered data? I appreciate any and all help!
Thanks! Sean Murphy "All things great and small start at the same point, the first step."
Hi Sean, May be I did not understand what you wanted, but I think Sharepoint is what you need. Or if you want an ASP.NET application, you will have to build a Custom CMS (content management system), where you can allow users to create something like articles and and then, when they submit the article, you can review them before it goes online.... If above does not makes any sense, I am sorry :)
-
Hi Sean, May be I did not understand what you wanted, but I think Sharepoint is what you need. Or if you want an ASP.NET application, you will have to build a Custom CMS (content management system), where you can allow users to create something like articles and and then, when they submit the article, you can review them before it goes online.... If above does not makes any sense, I am sorry :)
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
Name:
Address: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) foreach(HtmlElement elt in browser.Document.Forms) { foreach(HtmlElement ch in elt.GetElementsByTagName("INPUT")) { MessageBox.Show("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."
-
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
Name:
Address: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) foreach(HtmlElement elt in browser.Document.Forms) { foreach(HtmlElement ch in elt.GetElementsByTagName("INPUT")) { MessageBox.Show("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."
You can try writing client side code, javascript may be. In the textbox, you can register the script for key up (or some other as convenient) txtBox.Attributes.Add("onKeyup",javascript:ShowText(this.ID)"); and javascript: ShowText(param) { var textBox = document.GetElementByID(param); alert(txtBox.Value); } hope that does that.
-
You can try writing client side code, javascript may be. In the textbox, you can register the script for key up (or some other as convenient) txtBox.Attributes.Add("onKeyup",javascript:ShowText(this.ID)"); and javascript: ShowText(param) { var textBox = document.GetElementByID(param); alert(txtBox.Value); } hope that does that.
That lead me perfectly down the path I needed to go. Thanks RepliCrix! For anyone else out there, the code I used was 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
Box1:
Box2:
Box3://Send Back Input Values function SendTypedText(param) { var thisForm = document.forms[0]; window.external.ShowText(param, thisForm[param].value); }
Thanks! Sean Murphy "All things great and small start at the same point, the first step."