简体   繁体   中英

ASP.NET MVC: Return Control via controller for ajax call

Explanation of scenario:

I have a jquery window that will load up with a map control. This map control is a shared control in an asp.net MVC application. The way I've been told by Jquery developers is to use a $('').load(''); function to call into a controller which returns the control. Is this the best way? If so, how do i use the controller to return the control and in what format do i return it.

If this way is not right, could you please suggest an alternate way with tutorials to accomplish this please.

Thanks.

Just create partial view containing this control and define action:

public PartialViewResult MapControl(params)
{
    //Prepare model
    return PartialView("PartialViewName", model);
}

Then you can use jQuery.load() method. How does this control work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM