dnn mvc module not support Mvc Ajax and this make every thing hard to implement and jquery make us angry ! with this library we can use Ajax.ActionLink and BeginForm and Pagination and ... in dnn mvc module
To install DnnMvcAjaxHandler, run the following command in the Package Manager Console
pm> Install-Package DnnMvcAjaxHandler
You can also view the package page on NuGet.
<input type="hidden" value="@Dnn.ModuleContext.ModuleId" id="dnn-module-id" />
<input type="hidden" value="@Dnn.ModuleContext.TabId" id="dnn-module-tab-id" />
BeginFormto submit form you must implement html like bellow that have container with an id then pass that id to BeginForm:
<div id="search-form" class="form-inline">
<div class="form-group">
@AjaxHandler.CheckedChange(selected: false, linkText: "Ajax click me", actionName: "AddUserToRole", controllerName: "home", routeValues: new { userId = 1, roleId = 2 }, ajaxOption:
new AjaxHandlerOption
{
LoadingElementId = "#global-ajax-loading",
OnSuccess = "showMsg",
}, htmlAttributes: new { @class = "" })
</div>
<div class="form-group">
<input class="form-control" type="text" name="term" value="" placeholder="search ..." />
</div>
<div class="form-group">
@Html.DropDownList("SortBy", null, new { @class = "form-control" })
</div>
<div class="form-group">
@Html.DropDownList("SortOrder", null, new { @class = "form-control" })
</div>
<div class="form-group">
@AjaxHandler.BeginForm(btnText: "Search", actionName: "search", controllerName: "home",
ajaxOption: new AjaxHandlerOption
{
UpdateElementId = "#ajax-show-list",
TargetFormId = "#search-form",
LoadingElementId = "#global-ajax-loading",
}, htmlAttributes: new { @class = "btn btn-primary" })
</div>
</div>
just need to use ActionLink with needed parameter like this :
@AjaxHandler.ActionLink(linkText: "delete", actionName: "delete", controllerName: "home", routeValues: new { id = item.Id }, ajaxOption:
new AjaxHandlerOption
{
FadeColor = "#dc1821",
LoadingElementId = "#global-ajax-loading",
OnSuccess = "deleteRaw",
OnConfirm = "are you sure ?",
ClickedItemId = item.Id,
},
htmlAttributes: new { @class = "btn btn-danger btn-xs" })
for use pagination need to read pagedList library from here then we need to implement partial for pagination like bellow:
@inherits DotNetNuke.Web.Mvc.Framework.DnnWebViewPage
@using DnnMvcAjaxHandler;
@AjaxHandler.PagedListPager(actionName: "search", controllerName: "home",
routeValues: new
{
term = Request.QueryString["term"],
sortOrder = Request.QueryString["sortOrder"],
sortBy = Request.QueryString["sortBy"],
},
ajaxOption: new AjaxHandlerOption
{
UpdateElementId = "#ajax-show-list",
LoadingElementId = "#global-ajax-loading",
},
pagerOptions: new PagerOptions
{
currentPage = (int)ViewBag.CurrentPage,
PageCount = (int)ViewBag.PageSize,
TotalItemCount = (int)ViewBag.TotalItemCount,
DisplayMode = PagedListDisplayMode.IfNeeded,
DisplayPageCountAndCurrentLocation = true,
DisplayTotalItemCount = true,
LinkToNextPageFormat = "next",
LinkToPreviousPageFormat = "prev",
CurrentLocationFormat = "page",
PageCountFormat = "of",
TotalItemCountFormat = "total count",
WrapperClasses = "text-center",
}
)
this render checkbox with ajax click handler for us. just need to use CheckedChange with needed parameter like this :
@AjaxHandler.CheckedChange(selected: false, linkText: "Ajax click me", actionName: "AddUserToRole", controllerName: "home", routeValues: new { userId = 1, roleId = 2 }, ajaxOption:
new AjaxHandlerOption
{
LoadingElementId = "#global-ajax-loading",
OnSuccess = "showMsg",
}, htmlAttributes: new { @class = "" })
Task management application based on .NET 6 with DDD, CQRS, Event Sourcing and Testing Concepts
Create url shortener using django!
AJAX Live Search is a PHP search form that similar to Google Autocomplete feature displays the result as you type.
Unobtrusive Ajax Helpers (like MVC5 Ajax.BeignForm and Ajax.ActionLink) for ASP.NET Core
An e-commerce website using the Django framework.
Free and Open Source CMS based on ASP.NET Core and MongoDB
Mini Twitter project built with Django-framework with Bootstrap and Ajax