Dynamically load ASP.NET5 View Components using Jquery

December 01, 2015 by Anuraj

ASP.NET5 JQuery

Long back I wrote a post about loading partial views using JQuery. This post is about loading View Components in ASP.NET5 with the help of JQuery. Similar to previous versions of MVC, this version also supports returning View component from Action Result. So here is the controller code.

public IActionResult AddURLTest()
{
    return ViewComponent("AddURL");
}

You can load it using JQuery load method.

$(document).ready (function(){
    $("#LoadSignIn").click(function(){
        $('#UserControl').load("/Home/AddURLTest");
    });
});

Happy Programming.

Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub