Search code examples
asp.netreadable

Query regarding making the textbox readable?


I have an mvc application in which I want to make the texbox readable,i have used the following syntax it is not working.please tell me where am I going wrong

<%= Html.TextBox("upperlimit", String.Format("{0:F}", Model.upperlimit, new { @readonly = (Model.upperlimit != null ? "readonly" : "false") }))%>
<%= Html.ValidationMessage("upperlimit", "*") %>

Thanks in advance Ritz


Solution

  • Try this:

    <%= Html.TextBox(
        "upperlimit", 
        String.Format("{0:F}", Model.upperlimit), 
        new { 
            @readonly = Model.upperlimit != null ? "readonly" : "false" 
        })
    %>