atrljoe
atrljoe

Reputation: 8151

ModalPopupExtender Button Problem

I am trying to figure out why my ModalPopupExtender keeps closing, everytime a user clicks either button its running the code behind because I put a break point in and it is breaking there, but the modalPopup immediately closes, which isnt good because if it has any errors in the process they cant be displayed. So how do I stop the modalpopup from closing itself? I didnt specify a OKControlID or a CancelControlID.

Panel Code:

<asp:Panel ID="Panele" runat="server" style="display: none; position:absolute; top: 50%; left: 35%; width: 500px; height: 350px; background-color: White; border: solid 1px black; padding-left: 15px; text-align: left;">
        <asp:ImageButton ID="CloseEBtn" runat="server" 
        ImageUrl="images/CloseButton.png" style="float: right; margin-right: 3px; margin-top: 3px;" 
        onclick="CloseEBtn_Click" />
<strong>Name:<asp:TextBox ID="fromTextBox" runat="server"></asp:TextBox></strong>
    <asp:Button ID="SndBtn" runat="server" Text="Send" onclick="SndBtn_Click" />
&nbsp;<asp:Button ID="ClrBtn" runat="server" Text="Clear" />
    <br />
    <br />
    <asp:Label ID="msglabel" runat="server"></asp:Label>
</asp:Panel>

My ModalPopupExtender Code:

<asp:ModalPopupExtender ID="popup" runat="server" 
    TargetControlID="SIBtn" PopupControlID="Panele" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>

CodeBehind:

    protected void SndBtn_Click(object sender, EventArgs e)
    {
        msglabel.Text = "The Window Didnt Close";
    }
    protected void ClrBtn_Click(object sender, EventArgs e)
    {
        fromTextBox.Text = "";
        toTextBox.Text = "";
        subjectTextBox.Text = "";
        MessageTextBox.Text = "";
        msglabel.Text = "";
    }

Upvotes: 1

Views: 3287

Answers (2)

Niels Bos
Niels Bos

Reputation: 11

For me, UseSubmitBehavior="false" on the asp:Button did the trick.

Upvotes: 1

Brian Mains
Brian Mains

Reputation: 50728

By code-behind running if you mean the page posts back, modal popups do not explicitly reload themselves. You have to write some code from the server to show the Modal Popup; there is a Server-side Show() method on the extender and a client-side show() method like:

$find("<%= mpe.ClientID %>").show();

HTH.

Upvotes: 1

Related Questions