1

I have created the modal dialog box using the following javascript code :

<script type="text/javascript">
  function popThisUp()
    {
        var options = {
            url: "http://somehost/SitePages/View.aspx?IsDlg=1",
            width: 600,
            height: 300,
            title: "My First Modal Dialog",
        };

        SP.UI.ModalDialog.showModalDialog(options);
    }

</script>
<asp:Button ID="btnDialogDemo" runat="server" OnClientClick="popThisUp()" Text="Click here" />

I want to display my view site page or any page in the modal pop up on click of button but my modal dialog pops up for a second and then just closes on its own. I don't understand what is the problem here. Please help guys

1 Answer 1

1

just add return false; to avoid the postback caused by your asp button

 function popThisUp()
{
    var options = {

        url: "http://somehost/SitePages/View.aspx?IsDlg=1",

        width: 600,

        height: 300,

        title: "My First Modal Dialog",

    };
    SP.UI.ModalDialog.showModalDialog(options);
    return false;
}

OR use html button control so that there is no postback from the page

<input type='button' id="btnDialogDemo" onclick="popThisUp()" value="Click here"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.