我在我的项目中使用Asp.net/C#
,我有一个要求,在用户输入名称,并显示该人的详细信息asp.net gridview
,,,,我打算使用html button
而不是asp.net button
因为显示的结果将在tab中...然而,将填充gridview
的函数在code behind
,所以我的问题是如何从jquery
调用该方法,,,那是可能的。或者是否有任何更好的方式......提前谢谢
Have look to this post which describe you how to call function of code behind : Calling Server Side function from Client Side Script
Cs File (codebehind)
[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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.