0

I need to edit just few properties in my project, so I want to diable input into other textbox (it's already filled with informations).

Example:

@Html.ValidationSummary()
@using (Html.BeginForm("Uprav", "Dnes", FormMethod.Post, new { @class = 
"form-horizontal" }))
{
@Html.HiddenFor(x => x.Id)

<div class="form-group ">
    <label class="col-sm-2 control-label warning">Registrační číslo:</label>
    <div class="col-sm-2 ">
        @Html.TextBoxFor(x => x.Reg_cislo, new { @class = "form-control" })
        @Html.ValidationMessageFor(x => x.Reg_cislo)
    </div>
</div>

Filled from model:

@model ClassLibrary1.Model.Kolobezka

Could anyone help me please?

1
  • 1
    Can you re-write your question and make it more clear? Commented May 19, 2017 at 11:05

1 Answer 1

1

Try adding the readonly attribute:

<div class="form-group ">
    <label class="col-sm-2 control-label warning">Registrační číslo:</label>
    <div class="col-sm-2 ">
        @Html.TextBoxFor(x => x.Reg_cislo, new { @class = "form-control", @readonly = "true" })
        @Html.ValidationMessageFor(x => x.Reg_cislo)
    </div>
</div>

When the form is submitted you will obviously have to ignore that field server-side too (as 'readonly' won't stop someone inspecting, changing the value in the field and submitting data for that field)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.