Download the source from here  Install the Nuget package  Read the article on CodeProject.com  Visit our blog  Send feedback 
Demo

Click on the link and the submit button!

Last clicked: -

ActionLink: ActionLink

Ajax form:
#DIV1

Default content
#DIV2

Default content

1. Preparing the project

Configuring the handler Put this line in the web.config, under the <system.webserver> node:

                <add name="MultipartialHandler" path="multipartial.axd" verb="*" type="Pulzonic.Multipartial.Handler, Pulzonic.Multipartial" />
            
Including the JavaScript code Multipartial has a very small JavaScript code which does the DOM update. You can load this script through the JS handler of the Multipartial by including this code into your view of layout:

                <script type="text/javascript" src="Multipartial.axd?js"></script>
            

2. Usage

ActionLink View
                @Ajax.ActionLink("ActionLink", "ActionLinkClick", new AjaxOptions { OnSuccess = "MultipartialUpdate" })
            

Controller
                public ActionResult ActionLinkClick()
                {
                    MultipartialResult result = new MultipartialResult(this);

                    result.AddView("_Div1", "Div1", new Div1Model("ActionLink clicked"));
                    result.AddView("_Div2", "Div2", new Div2Model("ActionLink clicked"));
                    result.AddContent("ActionLink", "LastClickedSpan");
                    result.AddScript("alert ('ActionLink clicked');");

                    return result;
                }
            
Ajax form View
                @using(Ajax.BeginForm("FormSubmit", new AjaxOptions { OnSuccess = "MultipartialUpdate" }))
                {
                    <input type="submit" value="Submit">
                }
            

Controller
                public ActionResult FormSubmit()
                {
                    MultipartialResult result = new MultipartialResult(this);

                    result.AddView("_Div1", "Div1", new Div1Model("Form submitted"));
                    result.AddView("_Div2", "Div2", new Div2Model("Form submitted"));
                    result.AddContent("Form", "LastClickedSpan");
                    result.AddScript("alert ('Form submit clicked');");

                    return result;
                }
            

3. Frequently Asked Questions

Ajax.ActionLink not working, does a full redirect to a new page, rather than updating the DOM. You have to include some JavaScript files to use the MVC's Ajax functionality.

MVC 4:
Insert this line into the layout:
                @Scripts.Render( "~/bundles/jqueryval")
            

MVC 3:
Include these scripts:
<script src="/Multipartial/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
<script src="/Multipartial/Scripts/jquery.validate.min.js"type="text/javascript"></script>
<script src="/Multipartial/Scripts/MicrosoftAjax.js"type="text/javascript"></script>
<script src="/Multipartial/Scripts/MicrosoftMvcAjax.js"type="text/javascript"></script>
            

More infos about this are here and here.