Link to home
Start Free TrialLog in
Avatar of TrialUser
TrialUserFlag for Afghanistan

asked on

close ajaxmodal popup only if validation passes

I have a ajaxmodal popup , where user enters text in the textbox. When user clicks ok , I want to execute server side code and only if validation passes, I want to close he modal popup. please help how can I achieve this?
ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TrialUser

ASKER

How do I do : "and close the window depending on the result returned from server code. " is my question
SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, my question is how NOT to hide the popup when the validation fails on server side.
what are you using for the ajax?  jquery for example has a return event when data is received back (onSuccess).  Your server side script should send a flag back indicating whether or not the validation has been successful.  If it has hide() the dialog, otherwise do something else....

Can you post your existing code around the dialog box and ajax call so that I can show you what I mean
<asp:modalpopupextender ID="mpePromo" runat="server"
        TargetControlID="lbtnPromo" PopupControlID="pnlPromo"
        OkControlID="imgClosePopup" BackgroundCssClass="modalBackGround"
        DropShadow="true"></asp:modalpopupextender>
    <asp:Panel ID="pnlPromo" runat="server" CssClass="pnlmodalbgLegend" DefaultButton="ibtOkPromo">
       
            <div style="float:right; margin-top:-20px; margin-bottom:0px; margin-left:20px; margin-right:-30px; cursor:pointer;">  
                <asp:Image ID="imgClosePopup" runat="server" AlternateText="Close [ X ]" ImageUrl="/Assets/Images/ProductDetails/CloseModalPopup.png" OnClientClick="$find('ModalPopupExtender1').hide(); return false;"/>
            </div>
            <div style="margin-top:5px; margin-left:12px;">
            <table cellpadding="5" cellspacing="5">
                <tr>
                 <td>
                     <asp:Image ID="imgLogoPopUpProduct" runat="server" ImageUrl="~/Assets/Images/ProductDetails/paperclipslogopopup.jpg" />
                 </td>
                </tr>
                <tr id="trMsg" runat="server" visible="false">
                <td>
                    <asp:Label ID="lblMsg" runat="server" ForeColor="Red" Font-Size="14px" Font-Bold="true" style="margin-left:10px;"></asp:Label>
                </td>
                </tr>
                </table>
            </div>
            <div style="border-top:1px solid #CACACA;margin-top:15px;padding:10px;border-bottom:1px solid #CACACA;margin-left:auto;margin-right:auto;width:85%;">  
            <table width="100%" cellpadding="5" cellspacing="5">
                <tr>
                    <td align="right">
                        <asp:Label ID="lblPromoCode" runat="server" Text="Promo Code:" Font-Bold="True" Font-Size="17px" ForeColor="#333333"></asp:Label>
                    </td>
                    <td align="right">
                        <asp:TextBox ID="txtPromotionCode" runat="server" CssClass="TextBox" Height="20px" Width="200px" MaxLength = "50"></asp:TextBox>
                    </td>
                </tr>
            </table>        
        </div>
        <div style="text-align: right;margin:20px;">
            <asp:ImageButton ID="ibtOkPromo" runat="server" ImageUrl = "/assets/images/ShoppingCart/OK_off.jpg" />
            <asp:ImageButton ID="ibtCancelPromo" runat="server" ImageUrl = "/assets/images/ShoppingCart/Cancel_off.jpg" />
        </div>                                          
    </asp:Panel>  
Thanks for posting the code, however where is the javascript for the ajax call?
>OkControlID="imgClosePopup"
What happens if you remove that? Then in button click, run your server side code and then close the popup from server side

The technique would be similar to this

http://forums.asp.net/p/1016160/1366212.aspx