Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从C调用jQuery函数#_C#_Jquery_Asp.net_C# 4.0 - Fatal编程技术网

C# 从C调用jQuery函数#

C# 从C调用jQuery函数#,c#,jquery,asp.net,c#-4.0,C#,Jquery,Asp.net,C# 4.0,我有下面的函数需要从C调用# 有人能解释一下怎么做吗。我试着使用下面的代码 String csname1 = "PopupScript"; Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript; StringBuilder cstext2 = new StringBuilder(); cstext2.Append("<script type=\"text/ja

我有下面的函数需要从C调用#

有人能解释一下怎么做吗。我试着使用下面的代码

    String csname1 = "PopupScript";
    Type cstype = this.GetType();
    ClientScriptManager cs = Page.ClientScript;
    StringBuilder cstext2 = new StringBuilder();
    cstext2.Append("<script type=\"text/javascript\"> $('.image-cropper').each(linkUp); </");
    cstext2.Append("script>");
    cs.RegisterClientScriptBlock(cstype, csname1, cstext2.ToString(), false);
String csname1=“popuscript”;
类型cstype=this.GetType();
ClientScriptManager cs=Page.ClientScript;
StringBuilder cstext2=新的StringBuilder();
cstext2.Append(“$('.image-crapper')。每个(链接);”;
RegisterClientScriptBlock(cstype,csname1,cstext2.ToString(),false);

但它不起作用。

您真的应该在jQuery ready函数中调用代码,即:

$(function() {
    $('.image-cropper').each(linkUp);
});

代码无法运行的可能原因是,当代码运行时,DOM中没有图像裁剪器元素。

@rick Schott它没有调用您可能需要在
$(document.ready()
中包装JS的函数。因此,当您尝试选择元素时,会加载DOM。您使用的浏览器是什么?它是否有一个可以显示错误的开发控制台?我问,可能是在jQuery添加到页面之前,您发出的Javascript正在执行。这是许多问题的重复,但最近rick Schott回答了这一问题,为什么您的问题标记为
asp.net mvc
?我真诚地希望您不要在ASP.NET MVC应用程序中使用类似的东西。
$(function() {
    $('.image-cropper').each(linkUp);
});