>ASP.NET’s RegisterHiddenField and document.getElementById

>I was doing some testing today to find out why one of our ASP.NET web apps wasn’t working in Firefox. It boiled down to the fact that ASP.NET’s Page.RegisterHiddenField() method doesn’t set the ‘id’ attribute of the element it creates, only the ‘name’ attribute. This in turn breaks Firefox’s getElementById because in Firefox (and all other Mozilla-based browsers, as I understand) the id and name namespaces are not merged (as they are in IE). So getElementById() in Firefox will never find a hidden element created by using RegisterHiddenField().

The simple workaround is to use a HTML Hidden Input element as follows in the ASPX page:

<input type=”hidden” id=”myHiddenElement runat=”server” value=”myvalue” />

Then in the .cs codebehind you can declare your hidden element as follows:

protected System.Web.UI.HtmlControls.HtmlInputHidden myHiddenElement;

and you can manipulate the control in the codebehind as follows:

this.myHiddenElement.Value = “some value”;

I would consider this a bug in the RegisterHiddenField() but if someone can explain why it isn’t, I’d LOVE to hear why.


>February CTP Builds of VS 2005

>Microsoft has released the February CTP builds of Visual Studio.

More info here.

I haven’t had much time to play around with Visual Studio 2005 yet, but the time I have spent using it was very pleasant. The productivity improvements in the IDE are so nice (refactoring, Intellisense EVERYWHERE, etc). I’m also very excited about the two-way databinding for ASP.NET and the ClickOnce deployment for windows forms.