How do I render the partial view using jquery?
We can render the partial View like this:
<% Html.RenderPartial("UserDetails"); %>
How can we do the same using jquery?
How do I render the partial view using jquery?
We can render the partial View like this:
<% Html.RenderPartial("UserDetails"); %>
How can we do the same using jquery?
You'll need to create an Action on your Controller that returns the rendered result of the "UserDetails" partial view or control. Then just use an Http Get or Post from jQuery to call the Action to get the rendered html to be displayed.
You can't. You can, however, call a method (action) that will render the partial view for you.
$.get( '<%= Url.Action("details","user", new { id = Model.ID } %>',
function(data) {
$('#detailsDiv').replaceWith(data);
}
);
where the user controller has an action named details that does:
public ActionResult Details( int id )
{
var model = ...get user from db using id...
return Partial( "UserDetails", model );
}
I have used ajax load to do this:
$('#user_content').load('/User/UserDetails');