【问题标题】:call a JQuery function from code behind in C#从 C# 中的代码调用 JQuery 函数
【发布时间】:2013-10-01 22:52:33
【问题描述】:

我想从后面的 C# 代码中调用这个 JQuery 函数,但它不起作用 这是JQuery函数

function showDialog(id, title) {
$(id).dialog({
    modal: true, minWidth: 600, title: title
});
$(id).parent().appendTo($("form:first"));

}

这是我使用的代码

ClientScript.RegisterClientScriptBlock(this.GetType(), "myfunction", "$(document).ready(function(){showDialog('#editCustomer','نحديث معلومات عميل');});", true);

但这不行

【问题讨论】:

  • 注册clientscript,需要scriptmanager或者ajax toolkit script manager....

标签: javascript jquery c#-4.0 code-behind


【解决方案1】:
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "myfunction", "<script type='text/javascript'>myFunction(params...);</script>", true);

【讨论】:

    【解决方案2】:

    试试这个,

    ScriptManager.RegisterClientScriptBlock(this.Page,this.GetType(), "myfunction", "$(document).ready(function(){showDialog('#editCustomer','نحديث معلومات عميل');});", true);
    

    也可以先尝试将 jQuery 函数放入 $()。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-26
      • 1970-01-01
      • 2011-10-20
      • 2013-06-13
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      • 2013-07-28
      相关资源
      最近更新 更多