如何从C#调用的Jquery [英] How to Call Jquery from C#

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

问题描述

我试过打电话给对话框模型jQueryUI的

  $(函数(){
        $(#对话框的模式)。对话框({
            模式:真
        });
    });

利用C#

  ScriptManager.RegisterStartupScript(这一点,this.GetType(),脚本,对话();,真正的);

但是当我打电话的ScriptManager的jQuery是页面加载后执行,而不是

我怎么能做到这一点JQuery的功能时,在 ScriptManager.RegisterStartupScript 在C#中执行执行?

显然,我没有很好地解释:这个jQuery回发时执行especific功能的时候,我打电话,但在第一回发executting。我想code在执行过程中调用了jQuery。应该更具体些吗?


解决方案

  C#:
ScriptManager.RegisterStartupScript(此,this.GetType(),脚本,showMyDialog();,真);使用Javascript:
<脚本>
功能showMyDialog(){
  $(#对话框的模式)。对话框({
    模式:真
  });
< / SCRIPT>

I've tried to call the dialog-model jqueryui

$(function () {
        $("#dialog-modal").dialog({
            modal: true
        });
    });

from C# using

ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "dialog();", true);

but the JQuery is executing after page load and not when I call the ScriptManager.

How can I do that the JQuery function execute when the ScriptManager.RegisterStartupScript it execute in C#?

Apparently I did not explain well: This jquery I call during postback when execute especific function, but is executting in the first postback. I want call the jquery during the code execution. Should be more specific?

解决方案

C#:
ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "showMyDialog();", true);

Javascript:
<script>
function showMyDialog() {
  $("#dialog-modal").dialog({
    modal: true
  });
</script>

这篇关于如何从C#调用的Jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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