Jquery UI对话框问题 [英] Problem with Jquery UI Dialog box

查看:116
本文介绍了Jquery UI对话框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我在asp .net网站上使用Jquery UI功能。我在对话框中遇到一个小问题,我正在从代码后面显示对话框。在Jquery对话框中显示所有警报消息。到这里好了,我有一个问题,假设页面中发生异常然后我显示一个带有相应消息的消息框,显示消息框后,我将点击OK按钮,然后如果我重新加载相同的页面然后消息再次显示没有例外。



代码背后的代码是这样的:



 受保护  void  btnSum_Click(< span class =code-keyword> object  sender,EventArgs e)
{
try
{
int a = Convert.ToInt16(txta.Text);
int b = Convert.ToInt16(txtb.Text);
double c = a / b;
lblresult.Text = 结果是: + c;
ScriptManager.RegisterClientScriptBlock( this ,GetType(), script ShowDialog(););
}
catch (例外情况)
{
l2.Text = ex.Message;
ScriptManager.RegisterClientScriptBlock( this ,GetType(), script ErrorDialog(););
}

}





这是我的Jquery客户端脚本代码:



< script type =text / javascript> 


函数ShowDialog(){
$(function(){

$('#d1')。dialog({
modal:true,
autoOpen:true,
width:300,
draggable:true,
buttons:{
'OK':function(){$(this ).dialog('close');}
}
})
})。dialog();
}

函数ErrorDialog(){
$(function(){

$('#d2')。dialog({
modal:true,
autoOpen:true,
width:300,
draggable:true,
dialogClass:'error',
buttons:{
'OK':function(){$(this).dialog('close');}
}
})
})。dialog();
}

< / script>

解决方案

(function(){

('#d1')。dialog({
modal:true,
autoOpen:true,
width:300,
draggable:true,
按钮:{
'确定':function(){


(this).dialog('close');}
}
})
})。dialog();
}

函数ErrorDialog(){


Hi Friends,

I am using Jquery UI functionality in my asp .net web site. I have a small problem with Dialog box, I'm displaying Dialog box from code behind . displaying all alert messages in Jquery Dialog box.Till here Ok, I have a problem, suppose an exception occurs in a page then i'm displaying a message box with the appropriate message,After displaying message box , i'll click on OK button, then If i reload the same page then the message is displaying again without the exception.

My code behind code is something like this:

protected void btnSum_Click(object sender, EventArgs e)
    {
        try
        {
            int a = Convert.ToInt16(txta.Text);
            int b = Convert.ToInt16(txtb.Text);
            double c = a / b;
            lblresult.Text = "The result is :" + c;
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "script", "ShowDialog();", true);
        }
        catch (Exception ex)
        {
            l2.Text = ex.Message;
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "script", "ErrorDialog();", true);
        }

    }



This is my Jquery client script code:

<script type="text/javascript">


        function ShowDialog() {
            $(function () {
                
                $('#d1').dialog({
                    modal: true,
                    autoOpen: true,
                    width: 300,
                    draggable: true,
                    buttons: {
                        'OK': function () { $(this).dialog('close'); }
                    }
                })
            }).dialog();
        }

        function ErrorDialog() {
            $(function () {

                $('#d2').dialog({
                    modal: true,
                    autoOpen: true,
                    width: 300,
                    draggable: true,
                    dialogClass: 'error',
                    buttons: {
                        'OK': function () { $(this).dialog('close'); }
                    }
                })
            }).dialog();
        }

    </script>

解决方案

(function () {


('#d1').dialog({ modal: true, autoOpen: true, width: 300, draggable: true, buttons: { 'OK': function () {


(this).dialog('close'); } } }) }).dialog(); } function ErrorDialog() {


这篇关于Jquery UI对话框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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