我在我的项目中使用 Asp.net/C#,我有一个要求,即用户输入姓名并显示该人的详细信息 asp.net gridview ,,,, 我打算使用 html button 而不是 asp.net button 因为显示的结果将在选项卡中...但是将填充的函数gridview 位于 code behind 中,所以我的问题是我将如何从 jquery 中调用该方法,这是否可能。或者是有什么更好的方法可以做到这一点...... 提前致谢
请您参考如下方法:
看看这篇描述你如何调用后面代码函数的帖子:Calling Server Side function from Client Side Script
Cs 文件(代码隐藏)
[WebMethod]
public static string IsExists(string value)
{
//code to check uniqe value call to database to check this
return "True";
}
Javascript/jQuery
function IsExists(pagePath, dataString)
{
$.ajax({
type:"POST",
url: pagePath,
data: dataString,
contentType:"application/json; charset=utf-8",
dataType:"json",
error:
function(XMLHttpRequest, textStatus, errorThrown) {
alert("Error");
},
success:
function(result) {
alert( result.d);
}
}
});}
var pagePath = window.location.pathname + "/IsExists";
var dataString = "{ 'value':'ab" }";
IsExists(pagePath, dataString);
