How to push changes into HTMLDocument



I have a winform app that hosts the WebBrowser control.

I am working in C# in VS2k5.

Please note, I am using the managed wrapper for MSHTML.

I have event hooks to capture OnMouseOver and OnClick.

When the user mouse's over an HTMLElement I want to change the element's
background color or border so that the user can see the structure inside the
page/frame.

I have tried

setAttribute("style", "background-color: white",flags);

where flags = 1 or 0 (tried both) but the page does not reflect the change.

How can I push changes from C# code back into the web page.

1. Create a new winform application
2. Add a MANAGED reference (from the .NET tab) to Microsoft.mshtml
3. Open the form that is created by default.
4. Add a textbox called txtAddress
5. Add a button called btnNaviate
6. Add a WebBrowser control (you may need to add it to the toolbar, although
I didn't).
7. re-arrange the controls so you can see what you need to
8. add the code at the end of this message to the form.

Any help is much appreciated.

public Form1()
{
InitializeComponent();
webBrowser1.DocumentCompleted += new
WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
}

private void btnNavigate_Click(object sender, EventArgs e)
{
if (string.Empty != txtAddress.Text)
webBrowser1.Navigate(txtAddress.Text);
}

void webBrowser1_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
mshtml.HTMLDocument doc =
(mshtml.HTMLDocument)webBrowser1.Document.DomDocument;
mshtml.HTMLDocumentEvents2_Event browserEvent =
(mshtml.HTMLDocumentEvents2_Event)doc;
browserEvent.onclick += new
mshtml.HTMLDocumentEvents2_onclickEventHandler(browserEvent_onclick);
browserEvent.onmouseover += new
mshtml.HTMLDocumentEvents2_onmouseoverEventHandler(browserEvent_onmouseover);
}

void browserEvent_onmouseover(mshtml.IHTMLEventObj pEvtObj)
{
Console.WriteLine(pEvtObj.srcElement.tagName);
pEvtObj.srcElement.setAttribute("style", "background-color:
white",1);
}

bool browserEvent_onclick(mshtml.IHTMLEventObj pEvtObj)
{
Console.WriteLine(pEvtObj.srcElement.tagName);
return true;
}


.