• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Behrouz-Goudarzi/AjaxTagHelper: A simple solution to using links and ajax forms ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

Behrouz-Goudarzi/AjaxTagHelper

开源软件地址:

https://github.com/Behrouz-Goudarzi/AjaxTagHelper

开源编程语言:

C# 45.4%

开源软件介绍:

AjaxTagHelper

A simple solution to using links and ajax forms using Tag Helper in aspnet core

First, copy the AjaxTagHelper class from the Extensions folder to your project.

Second, copy the AjaxTagHelper.js file from js folder in wwwroot and add it to your project.

Then do the following: Open the viewImports file and add the following code

@using AjaxTagHelper.Extensions
@using AjaxTagHelper
@using AjaxTagHelper.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, AjaxTagHelper

To use Action Ajax, add the following code instead of the tag.

        <ajax-action ajax-action="Delete" ajax-controller="Home" ajax-data-id="@Model.Id"
                     class="btn btn-danger btn-sm" ajax-success-func="SuccessDelete">
            Delete
        </ajax-action>

Use the following code to use AJAX to send the form to server.

    <div class="row">
        <form id="frmCreate" class="col-sm-9">
            <div class="row">
                <div class="col-sm-4 form-control">
                    <input placeholder="Enter Name" name="Name" class="input-group" type="text" />
                </div>
                <div class="col-sm-4 form-control">
                    <input placeholder="Enter Family" name="Family" class="input-group" type="text" />
                </div>
                <div class="col-sm-4 form-control">
                    <input placeholder="Enter [email protected] " name="Email" class="input-group" type="email" />
                </div>
            </div>
        </form>
        <div class="col-sm-3">
            <ajax-button ajax-controller="Home" ajax-action="Create" ajax-form-id="frmCreate" ajax-success-func="SuccessCreate"
                         class="btn btn-sm btn-success">
                Create
            </ajax-button>
        </div>
    </div>

Finally, add the scripts you need to view it, check the code below

<script>
    function SuccessCreate(data) {
        console.log(data);
        $("#tbodyPerson").append(data);
   

    }
    function SuccessDelete(data) {
        $("#tr" + data.id).fadeOut();
    }
</script>
<script src="~/js/AjaxHelper.js"></script>



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap