jQuery的对话框回发的UpdatePanel,但没有更新 [英] jQuery Dialog-Postback but UpdatePanel doesn't get updated

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

问题描述

我想告诉从codebehind一个jQuery用户界面对话框,需要回发后刷新它。

i want to show a jQuery UI Dialog from Codebehind and need to refresh it after postbacks.

该对话框是控制来过滤和查找数据。所以用户从DropDownLists选择和在文本框输入文本,点击一个应用-按钮,异步回发发生时,根据用户的选择数据被过滤,其结果将在GridView显示。因此,我需要更新的UpdatePanel周围的GridView控件。

The dialog is a control to filter and find data. So the user selects from DropDownLists and enters text in TextBoxes, clicks a "Apply-Button", an asynchronous postback happens, the data gets filtered according to the user's selection and the result will be shown in a GridView. Therefore i need to update the UpdatePanel around the GridView.

异步回发的作品从这些链接的帮助:

The asynchronous postback works with help from these links:

  • <一个href="http://stackoverflow.com/questions/757232/jquery-ui-dialog-with-asp-net-button-postback">JQuery用户界面对话框与ASP.NET的按钮回发..
  • <一个href="http://blog.roonga.com.au/2009/07/using-jquery-ui-dialog-with-aspnet-and.html">http://blog.roonga.com.au/2009/07/using-jquery-ui-dialog-with-aspnet-and.html
  • JQuery UI Dialog with Asp .NET button postback..
  • http://blog.roonga.com.au/2009/07/using-jquery-ui-dialog-with-aspnet-and.html

(基本上 dlg.parent()appendTo(jQuery的(形式:一是)); 溶液)

问题:我无法更新的UpdatePanel既不的UpdateMode =永远也由手动通过UpdatePanel.Update codebehind()。我认为它有事情做与对话不是在UpdatePanel类似的或内部。希望有人能帮助我一起去。

Problem: I cannot update the UpdatePanel neither with UpdateMode="Always" nor manually from codebehind via UpdatePanel.Update(). I assume that it has something to do with the Dialog not being inside of the UpdatePanel or something similar. Hopefully somebody can help me along.

某些源代码:

function createChargeFilterDialog() {
    //setup dialog
    $('#Dialog_ChargeFilter').dialog({
        modal: true,
        resizable: false,
        autoOpen: false,
        draggable: true,
        hide: "Drop",
        width: 850,
        height: 600,
        position: "center",
        title: "Charge-Filter",
        buttons: {
            "Close": function () {
                $(this).dialog("close");
            }
        },
        open: function (type, data) {
            $(this).parent().appendTo(jQuery("form:first"))
        },
        close: function (type, data) {
        }
    });
}

它从codebehind调用时BtnShowDialog(jQuery的-对话外),通过

It gets called from codebehind when BtnShowDialog(outside the jQuery-Dialog) gets clicked via

AjaxControlToolkit.ToolkitScriptManager.RegisterStartupScript _
            (Me.Page, GetType(Page), "showChargeFilterDialog", "createChargeFilterDialog();$('#Dialog_ChargeFilter').dialog('open');", True)

更新:我也注意到,在回传值的问题。所有文本框如果为空或没有逗号追加。这表明,控制是根据呈现多次:<一href="http://www.componentart.com/community/forums/t/60999.aspx">http://www.componentart.com/community/forums/t/60999.aspx

Update: i've also noticed a problem in the postback-values. All TextBoxes if empty or not have a comma appended. This indicates that controls are rendered multiple times according to: http://www.componentart.com/community/forums/t/60999.aspx

我敢肯定,这两个问题是相关的。与所有控制整个对话将重新在每一个异步回发,因此所有控件名称中的DOM(导致ViewState的逗号追加发行)中存在多次。这些控件是唯一可见的萤火/ IE Deveoper工具栏,而不是在HTML源,因此,我认为jQuery的导致这些问题。我怎样才能处置对话框或如何能 prevent对话框的娱乐(检查是否已经存在)?这是因为该对话框里面一个UpdatePanel还是因为它的移动(通过Javascript)在UpdatePanel外?

I'm sure that both issues are related. The whole dialog with all its controls will be recreated in every asynchronous postback, hence all control names exist multiple times in the DOM(causing the ViewState comma-appending issue). The controls are only visible in FireBug/IE Deveoper Toolbar and not in HTML-Source, hence i assume that jQuery causes these problems. How can i dispose the dialog or how can i prevent the recreation(check if already exists) of the dialog? Is this because the dialog is inside an UpdatePanel or because it's moved(via Javascript) outside the UpdatePanel?

异步回发之前销毁对话框并不能解决问题,因为对话框将完全消失:

Destroying the dialog before async postback doesn't solve the problem because the dialog will simply disappear:

<asp:Button ID="BtnApplyFilter" OnClientClick="$('#Dialog_ChargeFilter').dialog('destroy');" ... />

您的帮助是很大的AP preciated。

Your help is greatly appreciated.

解决方案:我使用的<一个结束href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx">ModalPopupExtender从AjaxControlToolkit中。经过一番它的工作像异步回发一个魅力小问题(不要忘了叫 MPE.Show()在每code隐藏的功能,如果你想要的弹出留可见)。我可以添加更多的code,如果有人有兴趣。

Solution: i ended with using the ModalPopupExtender from the AjaxControlToolkit. After some small issues its working like a charm with asynchronous postbacks(don't forget to call MPE.Show() in every code-behind function if you want the popup to stay visible). I could add more code if anybody is interested.

推荐答案

下面是我如何解决同样的问题。它会删除所有旧的对话,并增加了新更新一回的形式使回传工作。我把那个被通过 ScriptManager.RegisterStartupScript 添加到页面背后的code脚本块以下code。

Here is how I solved the same issue. It removes any old dialogs and adds the newly updated one back to the form so the postbacks work. I put the following code in a script block that gets added to the page via ScriptManager.RegisterStartupScript in the code behind.

$('#divMyDialogAdded').remove();

$('#divMyDialog').dialog({
    autoOpen: false,
    modal: true
}).parent().appendTo('form:first');

$('#divMyDialog').attr('id', 'divMyDialogAdded');

这篇关于jQuery的对话框回发的UpdatePanel,但没有更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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