Reputation: 203
I want to get the value of the HiddenField in asp. However, the question is that HiddenField is created in program which is not from asp control.
protected override void OnInit(EventArgs e)
{
hd = new HiddenField();
hd.ID = "hdID"
hd.Value = jsonString;
this.Controls.Add(hd);
//........
base.OnInit(e);
InitializeControl();
}
Then when I trying to read its value..
var text = $("#<%=hdID.ClientID%>").val(); // fail, it says that the hd is not exist..
Upvotes: 1
Views: 48
Reputation: 5036
Try this:
$(document).ready(function () {
var text = $("#<%=hdID.ClientID%>").val();
}
Upvotes: 0