Try this.
javascript:
function SetHdnField() {
var x = document.getElementById('<%= hdnSomeField.ClientID %>');
x.value = 'hi';
return false;
}
aspx:
<asp:HiddenField runat="server" ID="hdnSomeField" />
<br />
<asp:Button runat="server" ID="btnSetValue" Text="Set Value" OnClientClick="return SetHdnField();" />
This works fine for me.