Michael Kniskern
Michael Kniskern

Reputation: 25270

ASP.NET validation not executing in a JavaScript showModalDialog call

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.

Upvotes: 2

Views: 2419

Answers (1)

Atanas Korchev
Atanas Korchev

Reputation: 30671

I think this may be due to a notorious problem with modal dialogs and postbacks. You can try adding the following in the head tag of the page which you open with window.showModalDialog

<base target="_self" />

Upvotes: 1

Related Questions