?
Solved

close ajaxmodal popup only if validation passes

Posted on 2011-10-14
10
Medium Priority
?
366 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:TrialUser
8 Comments
 
LVL 19

Accepted Solution

by:
Bardobrave earned 1000 total points
ID: 36968228
Well... you made an ajax call to your server code when the button is clicked on the modal window and close the window depending on the result returned from server code.
0
 

Author Comment

by:TrialUser
ID: 36968289
How do I do : "and close the window depending on the result returned from server code. " is my question
0
 
LVL 16

Assisted Solution

by:SriVaddadi
SriVaddadi earned 1000 total points
ID: 36968309
Here is my understanding

1. You show the modal popup
2. Execute client side validation when user clicks ok on the popup
3. If validation is successful you execute the server side code

Solution

Hide the popup from java script if the client side validation fails.  $find('mpePromo').hide();
Hide the popup from server code if the client side validation is successful. this.mpePromo.Hide();
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:TrialUser
ID: 36977479
Ok, my question is how NOT to hide the popup when the validation fails on server side.
0
 
LVL 43

Expert Comment

by:Rob
ID: 36983238
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
0
 

Author Comment

by:TrialUser
ID: 36986664
<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>  
0
 
LVL 43

Expert Comment

by:Rob
ID: 36997336
Thanks for posting the code, however where is the javascript for the ajax call?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37002708
>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
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question