答案 0 :(得分:0)
不幸的是,它并不像将JQuery值作为参数传递给C#函数那么简单。
理由:
为了将参数传递给服务器,您需要使用REST或SOAP消息传递实现一些API调用。
您还可以查看runat ='服务器'如果您不打算使用MVC / WebAPI / WCF,则标记旧的ASP.NET(非MVC)项目。
答案 1 :(得分:0)
我们不能直接在服务器端c#函数中传递jquery变量,但我们可以使用另一种方法来做,即通过调用另一个jquery方法,第二种方法使用jquery调用服务器端方法,ajax调用并且ajax方法在成功后返回所需的输出字符串。
{
name: 'Id', index: 'Id',
formatter: function (cellvalue, options, rowObject) {
var URLdata = "";
debugger;
BindTemperProofURL('@Url.Action("AddEventAttendee", "CampaignSchedule")', '', "Id=" + rowObject["Id"], function (data) { URLdata = data; })
return '<a href="' + URLdata + '" style="width:75px; "class="jqgridlink">' + rowObject["Id"] + '</a>';
}
},
function BindTemperProofURL(url, nonTamperProofParams, tamperProofParams, callback) {
var SecureURL = "";
debugger;
$.ajax({
type: 'POST',
url: '@Url.Action("SecureURL", "Base", new { area = string.Empty }, null)', // we are calling json method
dataType: 'json',
data: { url: url, nonTamperProofParams: nonTamperProofParams, tamperProofParams: tamperProofParams },
success: function (data) {
callback(data);
},
async: false,
error: function (ex) {
}
});