I want to load the same view again by passing updated parameter from text input on the link click. I tried to use something like <a href="@Url.Action("Index", "Home", new {id = "txtCount".value }). Not sure if there is even a way to do this. I know I could use partial but I want to reload the whole page with updated parameter. Thanks in advance for any help.
Controller
[HttpGet]
public ActionResult Index(int id)
{
return View(id);
}
View
@model int
@using (@Html.BeginForm())
{
<input id="txtCount" value="1" />
<a href="@Url.Action("Index", "Home", new { id = 5 @*// get value from txtCount*@ })">Update</a>
for (int i = 0; i < Model; i++)
{
<div>@i </div>
}
}
Maybe something like this
and binding with jquery
Obviously with the proper validations if the textbox is empty and all that stuff.
You cannot add the id value to the
@Url.Actionbecause it is processed before on the server side, before the page is rendered