dimanche 8 mai 2016

object name is bind as prefix in input control

currently I am working in asp.net mvc view

I create form using below code.

@{
    T4.Models.Order o = new T4.Models.Order();
}

@using (Html.BeginForm("Create", "Default5", FormMethod.Post))
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Order</h4>
        <hr />
        @Html.ValidationSummary(true)

        <div class="form-group">
           @Html.LabelFor(model => o.CustomerID, new {@class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model=>o.CustomerID)
                @Html.ValidationMessageFor(model => o.CustomerID)
            </div>
        </div>
   </div>
}

this code render perfectly but problem is it render with prefix of object's name.

show below html code

<input class="text-box single-line" data-val="true" data-val-required="The CustomerID field is required." id="o_CustomerID" name="o.CustomerID" type="text" value="">

you can see this html input control has id="o_CustomerID".I want that it only render with id="CustomerID".

I does not know why it takes object name as prefix.

please help me.

Thank You.

Aucun commentaire:

Enregistrer un commentaire