# [.net] getting html form data with C#

## Recommended Posts

I am trying currently to extract the data from my html textbox using a web control so i can save it but i am having no look at all. This is what i tried, string store = webbrowser1.document.getElementById("txt").innerText; that didn't do out at all.

##### Share on other sites
Hello again heh

Its been awhile since I have done that, but I think this should work

	foreach (mshtml.IHTMLElement wbrElm in HTMLDocument.all )			{				string strName;								if(wbrElm.tagName.ToLower() == "input" && wbrElm.outerHTML.IndexOf("name", 1) > 0)				{					strName = wbrElm.getAttribute("name", 0).ToString();

##### Share on other sites
would mshtml be the web control. In VB it would be variablenamehere = webbrowser1.document.all.getElementById("txt").value; i wish it was like that in C#.

##### Share on other sites
yeah, its different, the way Im doing it is putting the page into a webdoc and then parseing that as opposed to grabbing it right off the page like your trying to do. Im not saying it cant be done that way, just not a way i have done it in the past.

mshtml comes from adding a refernce to Microsft.mshtml

used for parseing that object.

##### Share on other sites
Just that i don't realy fully understand whats going on in the above code.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628328
• Total Posts
2982099

• 22
• 9
• 9
• 13
• 11