views:

236

answers:

1

A form contains many elements, such as labels, Textbox, radio options box etc

How do you detect the user has changed a textbox input value, or has choosen a radio option within the content of a web browser control? (not the winform itself).

Do you handle a winform event for when the mouse clicked or keyboard keys pressed? or is there a better way to detect changes in the web browser content?

A: 

There are "quick and easy" ways, but IMHO, a better way is to load the state of the form into javascript variables (on load), and then compare only the elements you are interested in, when navigating away, or whatever.

For example, there may be some fields that aren't so relevant (say, a different value in a minor drop-down box) but some that are very important (i.e. the contents of this message box).

It's fairly trivial to do anyway; just check the values you have currently (on the given event you are capturing, i.e. browser close) and then compare them with the ones you saved.

Noon Silk
What about doing this for a keypressed or mouse move event?----------------if (webBrowser1..Document.GetElementById("NAME").GetAttribute("value") != strDefaultNameValue){// field changed}
K001
Seems a bit wasteful to do it for every keypress, doesn't it?
Noon Silk