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?
Disabled fields are not posted. you can have a hidden field that holds the value if you need it posted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With