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

3 comments:

  1. Resources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
    AWS Training in pune
    AWS Online Training

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete