how to pass parameter to partial view in MVC4 razor

Posted by user2139492 on Stack Overflow See other posts from Stack Overflow or by user2139492
Published on 2013-05-20T11:42:17Z Indexed on 2013/10/31 21:55 UTC
Read the original article Hit count: 135

Filed under:
|
|
|

In my asp.net mvc 4 application i want to pass a parameter to partial view,however the parameter we want to pass is coming from javascript code

Below is the code

<script>
    var TestId;

 $(document).ready(function () {

        // Send an AJAX request       


        $.getJSON("/api//GetFun?Id="[email protected],

                function (data) {

TestId= data.Id
//i am getting the id here which i need to pass in partial view

}
1)...........
});


</script>

html code:

 <div id="tab1" >

 2)....      @{ Html.RenderAction("MyPartialView", "MyController", new { id = TestId });}
  </div>

So let me know how can i pass the test id to my partial view :in HTML(2) code or in javascript (1)

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about view