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:
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
Create 2 view models with properties CheckCost and PackageCost that way there's a seperation:
public class CheckViewModel{
public string CheckCost{get;set;}
}
public class PackageViewModel{
public string PackageCost{get;set;}
}
This way avoid conflicts.