jQuery的的UI模式确认里面asp.net按钮控制 [英] asp.net button control inside jquery-ui modal confirmation

查看:76
本文介绍了jQuery的的UI模式确认里面asp.net按钮控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我删除一个项目,并希望做所有的LINQ相关删除之前弹出一个确认窗口。

I'm deleting an item and want to pop-up a confirmation window before doing all the LINQ related deleting.

我要的是一个被加载到模态确认窗口然后执行服务器端的功能。

What i want is for an be loaded into the modal confirmation window to then perform the server-side functionality.

页上的按钮:

<input type="button" onclick="deleteConfirmation();" value="Eyða korti" id="btnDelete"/>

这是jQuery的的UI示例页面的JavaScript基本上是这样。
我不想按钮

javascript basically from jquery-ui sample page. I don't want the buttons

function deleteConfirmation() {

    $(".confirmation").dialog({
            resizable: false,
            height: 350,
            modal: true,
    });
}

标记加载到模式窗口:

markup to load into the modal window:

<div class="confirmation" style="display:none;">
Do you really want to delete...
<asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click" />
<input type="button" value="Cancel" class="button" />

毋庸置疑的onclick事件不会火起来。
我如何获得所需的功能。

Needless to say The OnClick event doesn't fire up. How do i attain the desired functionality.

编辑:
我也试过antoher事情

Edited: I also tried antoher thing

我把按钮的对话框内,然后返回真/假
然后让的OnClientClick =上的ASP按钮,在工作到一个点,因为在服务器端code运行,但弹出不等待用户输入回归deleteConfirmation()。

i put the buttons inside the dialog and then return true/false Then have the onclientclick="return deleteConfirmation()" on the asp button, that worked up to a point because the server side code runs but the popup doesn't await user input.

推荐答案

默认情况下jQuery的对话框克隆DOM元素,并将其放置在机身的结尾。

By default jQuery dialogs clone the dom elements and place them at the end of body.

这是表单标签之外。

既然是表单标签外,asp.net不接收这些事件。

Since it is outside the form tag, asp.net does not receive these events.

您需要将DOM放回​​形式。
事情是这样的:

You need to put the dom back into the form. Something like this:

function deleteConfirmation() {

    $(".confirmation").dialog({
            resizable: false,
            height: 350,
            modal: true,
    });

    //dialog put the asp elements outside form, bring it back

    $(".confirmation").each(function() { 
      var popup = $(this); 
      popup.parent().appendTo($("form:first")); 
    });

    //asp.net has its precious elements back into the form tag.

}

这篇关于jQuery的的UI模式确认里面asp.net按钮控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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