使用JQuery调用函数 [英] Calling function using JQuery

查看:81
本文介绍了使用JQuery调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我试图使用JQUERY调用函数后面的代码.
我给出了一个错误:
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

我粘贴了我的代码,它可能会给您提示,我要去哪里了

客户端:

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



它为intIterationid, btnPrevious, btnNext, btnFirst, btnLastrptQC, lblCurrentPage
提供了错误



It gives error for intIterationid, btnPrevious, btnNext, btnFirst, btnLastrptQC, lblCurrentPage

intIterationid is local variable
and rest are controls



此错误是因为我已声明函数共享,但是在声明共享之前,我无法使用JQuery调用此函数.

有提示吗?

在前进中感谢



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

推荐答案

("a [id


=" lnkQC]").click(function( ){
=''lnkQC'']").click(function() {


.ajax({ 输入:"POST", 网址:"Production_Iteration_myjob_view.aspx/fillRepeater", 数据: "{}", contentType:"application/json; charset = utf-8", dataType:"json", 成功:功能(数据){ 如果(data.d == 1) alert(成功"); 别的 alert("Error"); } }); });
.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



它为intIterationid, btnPrevious, btnNext, btnFirst, btnLastrptQC, lblCurrentPage
提供了错误



It gives error for intIterationid, btnPrevious, btnNext, btnFirst, btnLastrptQC, lblCurrentPage

intIterationid is local variable
and rest are controls



此错误是因为我已声明函数共享,但是在声明共享之前,我无法使用JQuery调用此函数.

有提示吗?

在此先感谢



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


这篇关于使用JQuery调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆