Currently, I want to pass the value from text box into Url.Action but I don't know how to do.
Create View
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<legend style="border-bottom: 3px solid #e5e5e5; text-align: center">TẠO BÁO CÁO TỒN KHO</legend>
<div class="container-fluid">
<div class="row">
<div class="row ">
<div class="form-group">
<label>Chọn </label>
@Html.EditorFor(model => model.Thang, new { htmlAttributes = new { @class = "form-control", style = "width:80px" } })
@Html.ValidationMessageFor(model => model.Thang, "", new { @class = "text-danger" })
</div>
</div>
<div class="row">
<div class="form-group">
<label>Chọn năm</label>
@Html.EditorFor(model => model.Nam, new { htmlAttributes = new { @class = "form-control", style = "width:80px" } })
@Html.ValidationMessageFor(model => model.Nam, "", new { @class = "text-danger" })
</div>
</div>
</div>
</div>
<div class="form-group">
<input type="submit" style="margin-left:15px" class="" value="" />
</div>
<div class="form-group">
<a href='@Url.Action("Index", "",new { thang = 1, nam = 2020 })'>
<input type="button" class="fa fa-pencil-square" />
</a>
</div>
</div>
}
I want to pass Url.Action with value which I typed from Model.Thang and Model.Nam instead of static value (1,2020). But when I change
<a href='@Url.Action("Index", "",new { thang = 1, nam = 2020 })'>
<input type="button" class="fa fa-pencil-square" />
</a>
into static value (1,2020). But when I change
<a href='@Url.Action("Index", "",new { thang = Model.Thang, nam = Model.Nam })'>
<input type="button" class="fa fa-pencil-square" />
</a>
It appeared errors.
System.NullReferenceException H Result = 0x80004003 Message=Object reference not set to an instance of an object.
Thank you for your helping!
User contributions licensed under CC BY-SA 3.0