Hi I am trying to refresh partial view with multiple parameters. I have got it to work with one parameter. How can I get it to work with more than one parameters. Here is the code, I have got so far. VIEW
@{
ViewBag.Title = "Report";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
$(document).ready(function () {
$("#serviceLine").change(function () {
var url = "/Home/PartialView1?serviceLine=" + $(this).val();
alert(url);
$("#reportContent").load(url);
});
$("#ClientID").change(function(){
var url = "/Home/PartialView1?ClientID=" + $(this).val();
alert(url);
$("#reportContent").load(url);
});
});
</script>
<h3>Report</h3>
<div>
<table>
<tr>
<td>Client</td>
<td>@Html.DropDownList("ClientList", null, new {id = "ClientID"})</td>
<td>ServiceLine</td>
<td>@Html.DropDownList("ServiceLine", null, new {id="serviceLine"}) </td>
</td>
</tr>
</table>
</div>
<div>
<h2>List</h2>
<div id="reportContent">
@Html.Action("PartialView1", new { clientID = 0, serviceLine = "_" })
</div>
</div>
CONTROLLER
public ActionResult PartialView1(int clientID, char serviceLine)
{
//Login
return PartialView();
}
ANY SUGGESTIONS PLEASE?
You could try this:
$.ajax({
url: "Home/PartialView1",
type: 'POST',
data: { "clientID": myclientId, "serviceLine" : myServiceLine }
}).done(function (data) {
div("#reportContent").html(data);
});
Just put all of the parameters in the data property.
You can use a jQuery ajax method and populate the results from the success
method. Something like:
$.ajax({
url: "@Url.Action("PartialView1", "Home")",
type: "POST",
data: { clientID: $("#ClientID").val(), serviceLine: $("#serviceLine").val() },
success: function (result) {
$("#reportContent").html(data);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.