Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Textbox Disabled... Cannot See the attribute in FormCollection

My Project is ASP.NET MVC one. In the view I am creating a Html Textbox and disabling it in the javascript using attr.

<script language="javascript">
Disable= function(){
  $("#Disable").attr("disabled","disabled");
}
</script>
<% using(Html.BeginForm("Save","Account")){%>
<%: Html.TextboxFor(model=>model.Account) %>
<input type="button" id="Disable" name="Disable" onclick="Disable()">
<input type="submit" id="Save">
<%}%>

When 'Save' button is hit I am catching the values in the FormCollection. But I could not see the Textbox in the collection when its get disabed. When it doesn't it works fine. Why does this happen?

like image 904
sunny Avatar asked Dec 22 '25 07:12

sunny


1 Answers

Disabled fields are not posted. you can have a hidden field that holds the value if you need it posted.

like image 195
ChrisThompson Avatar answered Dec 23 '25 21:12

ChrisThompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!