Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read only Textbox in ASP.net MVC View

Tags:

asp.net-mvc

How to set the readonly attribute to HTML Textbox helper class.

<%= Html.TextBox("Email", "[email protected]", new { @class = "required email" } )%> 

Appreciate your response Thanks

like image 932
Rita Avatar asked Jan 29 '10 18:01

Rita


People also ask

How set readonly property of TextBox in MVC?

The TextBoxes can be made ReadOnly by setting the HTML ReadOnly attribute using the HtmlAttributes parameter in Html. TextBox and Html. TextBoxFor helper functions.

How do I make a TextBox readonly in razor view?

Solution 1 In razor, everything is easy just add @readonly attribute to the code will do the needful.

How disable HTML TextBoxFor in MVC?

You can make the input 'read only' by using 'readonly'. This will let the data be POSTED back, but the user cannot edit the information in the traditional fashion. Keep in mind that people can use a tool like Firebug or Dragonfly to edit the data and post it back.


2 Answers

<%= Html.TextBox("Email", "[email protected]", new { @class = "required email", @readonly="readonly" }) %> 
like image 139
Alex LE Avatar answered Sep 30 '22 04:09

Alex LE


<%= Html.TextBox("Email", "[email protected]", new { @class = "required email", @readonly = "readonly" } )%> 
like image 25
Mattias Jakobsson Avatar answered Sep 30 '22 03:09

Mattias Jakobsson