Reputation: 35
How I can open asp.net MVC Partial View as popup window from controller action? I don't want to attach view from model class but should be open from controller action. Thank you.
Upvotes: 0
Views: 10656
Reputation: 17485
First of all you have to understand how asp.net mvc works.
You want to open popup window for partial view directly from Controller Action.
As per my opinion controller action does not aware of the thing that you have to open popup window or not. Its only responsibility is to server your request. How you display that depend on View.
Let me give you small example or small step.
In controller write one action ( Controller is for example HomeController)
public ActionResult Save()
{
return PartialView("save");
}
In Main view from where you have to open popup window do following thing.
$.ajax({
type: 'GET',
url: '/Home/Save' ,
success: function(data){
$('#popupDiv').html(data);
$('#popupDiv').show();
}
});
Above code is just steps and it is upto you which popup window you have to use Like Telerik , Bootstrap or your own implementation.
Upvotes: 1