jquery - how to pass parameter to partial view in MVC4 razor -


in asp.net mvc 4 application want pass parameter partial view,however parameter want pass coming javascript code

below code

<script>     var testid;   $(document).ready(function () {          // send ajax request                  $.getjson("/api//getfun?id="+@viewbag.id,                  function (data) {  testid= data.id //i getting id here need 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 pass test id partial view :in html(2) code or in javascript (1)

use below code in javascript , load view javascript function

var url = '@url.action("mypartialview", "mycontroller")'; url += '/?id=' + testid ; $("#tab1").load(url);  

put below code in controller

public actionresult mypartialview( int id ) {     return partial( "mypartialview", id ); } 

hope helps


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -