我如何从后面我的C#code。打开一个jQuery用户界面对话框? [英] How do I open a jQuery UI Dialog from my c# code behind?

查看:168
本文介绍了我如何从后面我的C#code。打开一个jQuery用户界面对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的ASP.NET C#code打开一个jQuery UI的对话框后面。我创建了code以下,但我不能让它工作,我不知道该如何调试问题。我怎样才能解决这个问题?

I am trying to open a jQuery UI Dialog from my ASP.NET c# Code Behind. I have created the code below, but I can't get it to work, and am unsure how to debug the problem. How can I resolve this issue?

我的javascript:

My JavaScript:

<script>
$(function () {
    $("#dialog_info").dialog("destroy");
    $("#dialog_info").dialog({
        autoOpen: false,
        modal: true,
        buttons: {
            Ok: function () {
                $(this).dialog("close");
            }
        }
    });
});
function show() {
    $("#dialog_info").dialog("open");
    return false;
}
</script>

我的HTML:

<body>
    <form id="form1" runat="server">
        <div>
            <div id="dialog_info" title="information">
                <asp:Literal ID="ltMessage" runat="server" Text="success"></asp:Literal>
            </div>
            <a href="#" id="message">open</a>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
    </form>
</body>

我的code背后:

My Code Behind:

protected void Button1_Click(object sender, EventArgs e)
{
    ltMessage.Text = DateTime.Now.ToString();
    StringBuilder sb = new StringBuilder();
    //sb.Append("<script> ");
    sb.Append("show();");
    //sb.Append("</script>");
    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "key", sb.ToString(), true);
}

修改code

功能showMessage(){

function showMessage() {

        $(function () {
            $("#dialog_info").dialog("open");
        });
        return false;
    }

现在工作得很好!

it works well now!

推荐答案

尝试使用<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript.aspx\"相对=nofollow> ScriptManager.RegisterStartupScript 方法

请参阅Difference的RegisterStartupScript和的RegisterClientScriptBlock之间?

这篇关于我如何从后面我的C#code。打开一个jQuery用户界面对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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