我有如下代碼如何使用Java腳本綁定網格我想調用aspx.cs代碼並檢索數據並綁定與網格沒有回發請幫助我。我是新的asp.net請幫助我。我有調用此方法,但沒有成功如何從asp.cs方法獲取JavaScript中的數據
<script type='text/javascript'>
$(document).ready(function() {
bindjs();
})
function bindjs() {
PageMethods.BindGrid(Success, Failure);
}
function Success(result) {
alert(result);
}
function Failure(error) {
alert(error);
}
</script>
和我Asp.cs方法是
[WebMethod]
public static DataTable BindGrid()
{
con = new SqlConnection(constr);
da = new SqlDataAdapter("select tblStudent.student_id,tblStudent.student_name,tblStudent.father_name," +
"tblStudent.Cell,tblStudent.parents_cell,tblStudent.admission_date,tblclassinfo.class_name,address_student" +
" from tblStudent inner join tblclassinfo on tblStudent.class_id = tblclassinfo.class_id", con);
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
您是否使用url:「http:// localhost:54913/pages/studentinformation.aspx」就像wcf for you? –
沒有它的網頁形式的頁面我想呼叫方法asp.cs方法 –
啊好的,所以你沒有調用你的JavaScript的任何職位,只有你已經公開你的方法和訪問從JavaScript,或trt這個http://www.c -sharpcorner.com/UploadFile/rohatash/calling-server-side-function-from-javascript-in-Asp-Net/ –