I used this to override framework generated id
@Html.EditorFor(model => model.cost, new { id = "checkCost" })
But unfortunately id is not changing. i.e
When i use
string d = Request.Form["checkCost"];
at controller action then string filled with null value.
WHY?? I also replaced EditorFor with TextBoxFor but nothing changed then also controller takes cost as ID
<td >
@Html.DropDownList("check_master", "--select package--")
</td>
<td >
@Html.EditorFor(model => model.check_name)
@Html.ValidationMessageFor(model => model.check_name)
</td>
<td >
@Html.EditorFor(model => model.cost, new { id ="checkCost" })
@Html.ValidationMessageFor(model => model.cost)
</td>
Updated:
- This is my partial view and my main view(rendering partial from ajax.actionLink) also hold a EditorFor(model=>mode.cost)
- Partial view is strongly typed to Check_master table and main view is strongly typed to package_master where both entitySet hold same name property i.e "COST" Secondly both partial and main view hold EditorFor "cost"
I tried to change the name of check_master property like by - [Column("check_cost")]
public Nullable cost { get; set; }
But dont know why this is not working i.e property naem is not changing while referring it like
model.something