I have two pages. From the first page, I open a modal with a querystring that holds that value of a client name. I then use this to set a hiddenfield on the modal that opene
Because jQuery knows nothing about asp:HiddenField
. It looks in the HTML structure where you have . So there's no input with
ID= HiddenFieldServerDateTime
. There are a few ways to overcome this:
Use a css selector:
with the following selector: var serverDateTime = $(".SomeStyle").val();
CssClass
is not an available class on the HiddenField class (and it doesn't have an Attributes collection, so you can't add it manually).
Use ClientID
property:
var serverDateTime = $("#<%= HiddenFieldServerDateTime.ClientID %>").val();
Wrap the hidden field in something you can select:
var serverDateTime = $('.date-time-wrap input[type=hidden]').val();