I have a component that determines a value on a postback event.
protected void Button_Click(object s, EventArgs e)
{
HiddenField.Value = 5;
}
There's more involved in the value of course, but HiddenField is an asp:HiddenField control with runat=server set. I have in my javascript:
var id = $("#<%= HiddenField.ClientID %>").val();
The code in the javascript is set to be run only after the postback has occured (a different client click event) for the purpose of passing the hidden field value via QueryString to another URL (since i can't do a response redirect on postbacks and the client wants it in a different page anyway).
I tried adding:
ScriptManager.RegisterHiddenField(HiddenField, "Value", string.Empty);
To a !Page.IsPostback section of code, but the ID is still not set when the javascript is run.