从 html 按钮触发 c# 代码绑定

Fire c# codebind from html button

我正在使用 Jquery DataTables,使用 ajax 和 c# 加载数据。对于其中一个 table,我需要触发一个事件,该事件触发使用 ASP.NET 报告查看器生成报告。

我遇到的问题是绕过按钮以触发代码隐藏页面中的方法。

使用 ColumnDefs 选项,在 JQuery DataTables 中,我呈现以下创建按钮的内容:

 {
    "targets": 9,
    "data": "download link",
    "render": function(data, type, full, meta) {
        return '<button id="btnViewReport" type="button" class="remove" runat="server" value="' + data.Id + '">View Report</button>';
    }
}

这显示在我的 table 中很好,但现在我需要点击事件来触发报告。我的印象是,添加 runat="server" 会起作用,但可惜没有快乐。

首先,是否可以使用调用 none 静态方法的 JQuery 添加按钮?

问题是"runat server"。您需要创建一个 html 按钮(像这样 <button id="myid" class="myclass" ></button>),并使用 jQuery 创建一个函数,然后您可以使用 QueryString 或 Ajax 调用来调用您的方法!