0

I have this button here actual It is made of aspx.net html. When I click this button I wanted to popup a modal. Making modal is easy to do, but in my case I wanted to call another web page(Printer.aspx) of my server.

<td>
  <Button ID="btnPrint" runat="server" OnClick="Printer_Click" >Printer</Button>
</td>

Here is js code. With this code I was able to open new window as a popup but I wanted to call Printer.aspx in my show modaldiv

    //Printer button click function
    function Printer_OnClientClick(){
        var returnValue = showPopUp('Printer.aspx', 700, 500);
        if (returnValue != null) {
            return true;
        }
        return false;
    }
      //showPopUp function 
 function showPopUp(url,winName,w,h,scroll, clientID){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
        TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
        settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'

    if (url.indexOf("?") == -1)
    {
        url = url + "?";
    }else {
        url = url + "&";
    }
    url = url + "PageId=" + $('#hiddenPageDataId').val();

    var timstamp= new Date().getTime();
    url = url + "&timstamp=" + timstamp;

    try {
    popupWindow = window.open(url,winName,settings) // This will open new tab 
    } catch(e) {
        popupWindow = null;
    }
        
    if (clientID== null){
        return popupWindow;
    } else {
        if (popupWindow != null) {
            $('#' + clientID).val(popupWindow);
        }
        return false;
    }
}

Please do not get confused this Js is which I made to do window.open(), but now I wanted to call the next page in modal iframe. I also have another js which I discovered in Google here it is:

  $(document).ready(function () {
    $(".PrinterSelect").click(function () {
        $("#iFrameDialog").attr('src', $(this).attr("href"));
        $("#divDialog").dialog({
            width: 400,
            height: 450,
            modal: true,
            close: function () {
                $("#iFrameDialog").attr('src', "about:blank");
            }
        });
        return false;
    });
});

This will work in html page, but I wanted to do it with an aspx page.

  • 1
    https://stackoverflow.com/questions/24801124/how-to-make-window-open-pop-up-modal – MD. RAKIB HASAN Feb 09 '21 at 09:19
  • 1
    thank you for your recomendation but It is not exactly what I wanted and I already read this article It is possible if i had href in my button we can use attr('src', $(this).attr("href")); and call iframe but in aspx couldn`t write href . –  Feb 09 '21 at 09:28

0 Answers0