PARENT.ASPX

 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

        '********************************************************************************

        'This code will create the __DoPostback function on the client side page

        Page.ClientScript.GetPostBackEventReference(New Web.UI.PostBackOptions(Me.Page))

        '********************************************************************************

 

 

        If Page.IsPostBack Then

            Dim requestTarget = Me.Request("__EVENTTARGET")

            Dim requestArgs = Me.Request("__EVENTARGUMENT")

            Response.Write("Hello " & requestTarget)

        End If

 

    End Sub

 

 

   <link rel="stylesheet" href="jquery-ui-1.12.1/jquery-ui.css">

   <script src="jquery-ui-1.12.1/jquery.js"></script>

   <script src="jquery-ui-1.12.1/jquery-ui.js"></script>

.

.

.

 

 

    <form id="form1" runat="server">

        <div>

            <input id="Button1" type="button" value="button" />

        </div>

    </form>

.

.

.

 

 

<script>

 

    var MyDialog1;

    $("#Button1").on("click", function () { OpenPage('Mytitle', '200', '200', 'Child.aspx');return false });

    

    function OpenPage(sTitle, iHeight, iWidth, PageName) {

 

      

        //***************************************************************************************************        

 

        $('head').append('<style type="text/css">.ui-widget-overlay.ui-front {opacity:.75; }</style>');

 

        //***************************************************************************************************                  

 

 

        MyDialog1 = $("<div></div>").html("<iframe  id='MyIFrame' style='border: 0px; ' src='" + PageName +  "' width='100%' height='100%'></iframe>")

            .dialog({

               // buttons: [{ text: "Close", click: function () { $(this).dialog("close"); } }],

                autoOpen: false,

                modal: true,

                height: iHeight,

                show: { effect: 'slide', duration: 1000 },

                hide: { effect: 'slide', duration: 1000 },

                width: iWidth,

                close: function () { __doPostBack("This is my event target", '') }

                // beforeClose: function (event, ui) { alert('your closing!') }

 

            })

        // Open without the 'x' on the upper right of the window...

        MyDialog1.dialog('open').prev().find(".ui-dialog-titlebar-close").hide();;

 

    } //OpenPage Function

 

 

 

    function closeIframe(SomeParameter) {

        //********************************************************************************************************************************************

        //This function is called from the Child page,(Detail.aspx), like this: Dim sScript As String = “<scrpt>window.parent.closeIframe();</scrpt>”

        //                                                                      ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyKey", sScript, False)

        //**********************************************************************************************************************************************

        MyDialog1.dialog('close');

        return false;

    } //CloseIframe

 

 

 

</script>

 

 

CHILD.ASPX

 

 

Protected Sub cmdClose_Click(sender As Object, e As EventArgs) Handles cmdClose.Click

 

        Dim s As String = "<script>window.parent.closeIframe();</script>"

        ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyKey", s, False)

 

    End Sub

 

 

 

BONUS CODE     linkbutton click finds selected value in listbox

 

<asp:LinkButton ID="lbAddNote" OnClientClick="GetSelectedItem();return false;" runat="server" Font-Names="Arial" Font-Size="11pt">Booklet Notes...</asp:LinkButton>

 

 

   function GetSelectedItem() {

        iFound = 0;

        sel = document.getElementById('lbBooks')

        var listLength = sel.options.length;

        for (var i = 0; i < listLength; i++) {

            if (sel.options[i].selected) {

                iFound = 1;

                OpenPage('Notes', '330', '480', 'AddNote.aspx', sel.options[i].value)

            }//if selected

        }//for loop

 

        if (iFound != 1) { alert('select first') }

    }// GetSelectedItem