1

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?

1
  • Check here Commented May 8, 2013 at 12:08

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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);
    }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.