Showing posts with label MVC ReadOnly textbox. Show all posts
Showing posts with label MVC ReadOnly textbox. Show all posts

Friday, October 12, 2012

Create a Read-only Textbox using ASP.NET MVC Html Helper

Explore the Top Microsoft SQLServer Technical/ Interview Questions here: http://XploreSqlServer.blogspot.com/
   
Explore the Top Microsoft C# Technical/ Interview Questions here: http://XploreCSharpDotNet.blogspot.com

Explore the Top Microsoft Blazor Technical/ Interview Questions here: https://XploreBlazor.blogspot.com/

The following razor code nugget creates a read only textbox with the Id, txtCity and the value, "Chennai" :

                 @Html.TextBox("txtCity", "Chennai", new { @readonly = "readonly" })

The nugget generates the following HTML:

                 <input id="txtCity" name="txtCity" readonly="readonly" type="text" value="Chennai" />

The following nugget is to create a read only textbox bound to the model property, City :

       @Html.TextBoxFor(model => model.City, new { @readonly = "readonly" })



Explore the Top Microsoft SQLServer Technical/ Interview Questions here: http://XploreSqlServer.blogspot.com/

Explore the Top Microsoft C# Technical/ Interview Questions here: http://XploreCSharpDotNet.blogspot.com