0
votes

I've got a page that opens a modal (Page1.aspx). That modal is another aspx page (Page2.aspx).

How can I declare in the opener page (or any other way), that a modal button, executes a button click in Page2.aspx.

I've tried to put:$('#ButtonOK').click(); (as it's the buttons id), but on the parent page it isn't recognized.

How can I execute that click?

Many thanks.

MY CODE, PAGE1:

function createModal(f,w,h) {
            var dialogWidth = w;
            var dialogHeight = h;

        $('#dialog').dialog({
            autoOpen: false
            , bigframe: false
            , modal: true
            , width: dialogWidth
            , height: dialogHeight
            , autoResize: true
            , closeOnEscape: true
            , position: { my: "center", at: "center", of: window.top }
            , open: function (event, ui) {
                $('#dialog').css('overflow', 'hidden'); //this line does the actual hiding
            }
            ,buttons: {
                Ok: function () {
                    $("input[id$='ButtonOK']").trigger('click');
                },
                Cancelar: function () {
                    $(this).dialog("close");
                }
            }
        });
        $('#dialog').dialog('open');
        $("#iframe").attr('src', f);
        return false;
    }

    function PermMV(usr) {
        createModal('new.aspx?usr=' + usr,350,450);
    }

<div id="dialog" style="display: none;"> <iframe id="iframe" width="100%" height="100%" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" align="middle"></iframe> </div>

PAGE 2: <div id="acrescenta2" title="Perm"> <asp:TextBox ID="txtuser1" name="txtuser" runat="server" Text="" CssClass="consprodtxt" /> <asp:Button ID="ButtonOK" runat="server" OnClick="ButtonOK_Click" OnClientClick="ButtonOK_Click" Text="OK" CssClass="btnmv" /> </div>

Hope that helps.

3

3 Answers

0
votes

You need to use IFrame Like This,

<div class="modal-body" id="modal_dialog">
<iframe style=" width:100%; height: 100%;" id="ifrm" src="yourExternalPage.aspx" runat="server">
</iframe>

And Open This Div as a Dialogue using JQuery,

<script type="text/javascript">
    $("#BtnClick").live("click", function () {
        $("#modal_dialog").dialog({
            title: "jQuery Modal Dialog Popup",
            buttons: {
                Close: function () {
                    $(this).dialog('close');
                }
            },
            modal: true
        });
        return false;
    });
</script>

1<>Simple jQuery Modal Popup Window Example in ASP.Net

2<>Modal popup using jquery in asp.net

-1
votes
$(document).on("click","element",function(args){
    //...
});

Try it

-1
votes

Try this:

$("#ButtonOK").trigger('click');