I am setting a TextBox
controls value via an ajax post.
$(\'#txtSite\').val(msg.d.SiteName);
This is working and the value of the
You have your textbox set to Enabled="false"
which renders in the browser with a disabled="disabled"
. Disabled form inputs are not submitted.
The solution is either to make the textbox enabled and read-only:
txtSite.Enabled = true;
txtSite.Attributes.Add("readonly", "readonly"); //on prerender event or somewhere else
or to use a different element set with runat="server"
, like a
and update both the textbox and the alternate element with your AJAX call:
success: function(msg) {
if (msg.d != null) {
$('#txtSite').val(msg.d.SiteName);
$('#hiddenInput').val(msg.d.SiteName);
} else {
$('#txtSite').val('');
}
}