Click here to Skip to main content
15,112,662 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
JavaScript
<script type="text/javascript">
    $(document).ready(function () {
        $(".DeleteButton").click(function () {
            var flag = window.confirm("?");
            var deleteid = $(this).attr("deleteid");
            if (flag == true) {
                $.post("/Biography/Delete", { id: deleteid }, function (data) {
                    $("#content").html(data);
                });
            }
        });

        $(".EditButton").click(function () {
            var editid = $(this).attr("editid");
            $.get("/Biography/Edit", { id: editid }, function (data) {
                $("#content").html(data);
            });
        });
</script>



HTML
.Columns(columns =>
                     {
                         columns.Bound(b => b.ID);
                         columns.Bound(b => b.Name);
                         columns.Bound(b => b.Sex);
                         columns.Bound(b => b.Department);
                         columns.Bound(b => b.Post);
                         columns.Bound(b => b.Degree);
                         columns.Template(b => @Html.Raw("<input class='DeleteButton' type='button' value='Delete' deleteid='" + b.ID + "'/>"
                                        + "<input class='EditButton' type='button' value='Edit' editid='" + b.ID + "'/>"))
                                         .ClientTemplate("<input class='DeleteButton' type='button' value='Delete' deleteid='<#= ID #>'/>"
                                        + "<input class='EditButton' type='button' value='Edit' editid='<#= ID #>'/>");
                     })

When page or filter after,the button is disabled.
Posted
Comments
   
Not a question.
--SA

1 solution

HTML
.Filterable()
            .ClientEvents(events => events
                         .OnDataBound("onDataBound")
            )

JavaScript
function onDataBound() {
        $(".DeleteButton").click(function () {
            var flag = window.confirm("?");
            var deleteid = $(this).attr("deleteid");
            if (flag == true) {
                $.post("/Biography/Delete", { id: deleteid }, function (data) {
                    $("#content").html(data);
                });
            }
        });

        $(".EditButton").click(function () {
            var editid = $(this).attr("editid");
            $.get("/Biography/Edit", { id: editid }, function (data) {
                $("#content").html(data);
            });
        });
    }
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900