I want to get the value of textbox inside partial view inside the anchor link tag so that i can pass the value to the controller from the anchor link tag every time i click on the link. How can i perform this action. Please give some suggestion.. Thanks...
ViewUser.cshtml
@model IEnumerable<Search_Paging.Models.tbl_product>
<html>
<head>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.linkAction').click(function (e) {
$('.linkAction').attr('href', '@Url.Action("UsersList", "Home", new { str = "---" })'.replace("---", $('.txtString').val()));
});
e.preventDefault();
});
</script>
</head>
<body>
@Html.TextBox("Strings", null, new { @class = "txtString" })
<input type="button" value="filter" id="Button1" />
<div class="pagination">
@for (int p = 1; p <= ViewBag.Total; p++)
{
<a href="@Url.Action("UsersList", "Home", new { str = "---" })" class="linkAction">@p</a>
}
</div>
</body>
</html>
getUsersList.cshtml (Partial View)
<h2>@ViewBag.strings</h2>
HomeController.cs
[HttpGet]
public ActionResult ViewUser()
{
ViewBag.Total = 15;
return View();
}
[HttpGet]
public ActionResult UsersList(string str)
{
ViewBag.strings = str;
return PartialView("UsersList");
}