I’ve recently spent some time tracing cross browser issues with Silverlight 3, and one in particular irked me a little.

With one project, I used the HtmlPage.Document.GetElementById managed code to get information (and ultimately set them) in HTML pages.

However, it seems this does not work properly with Chrome and Firefox. On the surface it all seems to work fine, however, settings values definitely was not working as it should.

So, the work around is a basic JavaScript function such as :

function getValue(elementName) {
var result = document.forms[“formhere”].elements[elementName];
if (result != null) {
return result.value;
return “”;

And then calling out to this using HtmlPage.Window.Invoke(“doSomething”);

This works :)  A bit messy, but at least it DOES work reliably, unlike the built in GetElementById. Here’s hoping it’s fixed in Silverlight 4.