Hello friends,
I was trying to call code behind function using JQUERY.
I gives an error:
Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class
I paste down my code it might give you hint, where I'm going wrong
Client Side:
$("a[id$='lnkQC']").click(function() {
$.ajax({
type: "POST",
url: "Production_Iteration_myjob_view.aspx/fillRepeater",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
if (data.d == 1)
alert("Successful");
else
alert("Error");
}
});
});
Code Behind:
<system.web.services.webmethod()> _
Public Shared Function fillRepeater() As Integer
Dim objDT As New DataTable
Try
objDT = AliaDAO.clsQualitycheck_DAO.getFilterDailyDetails(2, intIterationid)
'Create the object of PagedDataSource
Dim objPDS As New PagedDataSource
'Assign our data source to PagedDataSource object
objPDS.DataSource = objDT.DefaultView
'Set the allow paging to true
objPDS.AllowPaging = True
'Set the number of items you want to show
objPDS.PageSize = 10
'Disable First, Prev, Next, Last buttons
btnPrevious.Enabled = Not objPDS.IsFirstPage
btnNext.Enabled = Not objPDS.IsLastPage
btnFirst.Enabled = Not objPDS.IsFirstPage
btnLast.Enabled = Not objPDS.IsLastPage
'Assign PagedDataSource to repeater
rptQC.DataSource = objPDS
rptQC.DataBind()
'Change the text Now viewing text
lblCurrentPage.Text = "Now viewing : " & (NowViewing + 1).ToString() & " of " & objPDS.PageCount.ToString()
Catch ex As Exception
Return -1
End Try
Return 1
End Function
It gives error for
intIterationid, btnPrevious, btnNext, btnFirst, btnLastrptQC, lblCurrentPage
intIterationid is local variable
and rest are controls
This error is because I have declared function shared, but until I declare shared I cant call this function using JQuery.
Any hint??
Thanks in Advance