Click here to Skip to main content
15,867,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Im having trouble disabling or set textbox to readonly after postback submission.
what code do i need from controller to disable a razor textbox in views.
please dont suggest to use jquery for me to familiarize mvc thanks.

What I have tried:

i can do this by default but cant control the properties of the textbox in the c# controller.
<input id="Name" name="Name" type="text" value="@Model.listovariableclass" disabled="disabled"
Posted
Updated 22-Oct-20 8:17am
Comments
khezerloo 8-Jan-18 15:32pm    
ll

MVC is a server-side technology, you can't use it to dynamically amend the DOM in the browser, so I'm afraid you're going to have to use javascript or jQuery to do this.
 
Share this answer
 
Solution by ROCH DEVELOPER

@Html.EditorFor(model => model.Consecutive, new { htmlAttributes = new { @class = "form-control", @Value = ViewBag.Consecutivo, disabled = "disabled" } })
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900