ASP.NET validation not executing in a JavaScript showModalDialog call

Posted by Michael Kniskern on Stack Overflow See other posts from Stack Overflow or by Michael Kniskern
Published on 2009-02-18T15:38:26Z Indexed on 2010/04/19 8:13 UTC
Read the original article Hit count: 669

I currently open a pop up window from my parent page using using a JavaScript .showModalDialog function. The pop up window contains some ASP.NET validation controls which do not display when the user clicks the ASP.NET button to submit the form. If there is an error on the page, the validation message(s) do not display, the record is not updated on the server side and the pop window closes.

(The asp.net validation controls do not stop the pop up window from doing a server postback)

Has anyone expereinced this behavior before and is there any way to prevent it?

Here is my showModalDialong call source code:

function OpenChildWindow(id)
{
    var sFeatures = sFeatures="dialogHeight: 525px;";
    sFeatures += "dialogWidth: 900px;";
    sFeatures += "scroll: yes;";
    sFeatures += "status: no;";
    sFeatures += "resizeable: no;";

    var url = "MyPopUp.aspx?ID=" + id;
    var childName = "ChildForm";

    entryWindow = window.showModalDialog(url, childName, sFeatures);

    if (entryWindow == true)
    {
        window.document.getElementById("<%= btnUpdateParent.ClientID %>").click();
    }
}

Note: When the pop up modal is closed, a ASP.NET button is "clicked" to update an ASP.NET UpdatePanel on the parent to show the changes to the record modified in the pop up window.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript