Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a ModalPopupExtender where I show a image of work in progress while printing a report.
I have to take some user input before the user click to show rpeort button.
A validation extender is used for the input validation.

How can I stop the popuop extender to show if the input is not valid?
Posted
Updated 27-Feb-11 1:25am
v2
Comments
Dalek Dave 27-Feb-11 7:25am    
Edited for spelling and readability

hi
you may like to try this example..

XML
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
 <asp:ScriptManager runat="server" ID="script1"></asp:ScriptManager>
 <script type="text/javascript">
     function showModalPopup() {
         if (document.getElementById("<%=TextBox2.ClientID %>").value == "") {
             alert("No of copies should not be blank");
             $find('popup1', null).hide();
         } else {
             $find('popup1', null).show();
         }
     }
 </script>
    <asp:Panel ID="Panel1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Ready To Print"></asp:Label>
        <asp:Button ID="Button1" runat="server"  Text="Start Printing" />
        <asp:Button ID="Button4" runat="server"  Text="Cancel" />
    </asp:Panel>

    <asp:Label ID="Label2" runat="server" Text="Enter No of Copies"></asp:Label>
    <asp:TextBox ID="TextBox2" runat="server" ValidationGroup="Test"></asp:TextBox>
    <input type="button" id="Button3" runat="server" onclick="showModalPopup();" value="Submit"   />
    <asp:ModalPopupExtender ID="Button2_ModalPopupExtender" runat="server"   BehaviorID="popup1"
        DynamicServicePath="" Enabled="True" TargetControlID="Button2"   PopupControlID="Panel1"
         CancelControlID="Button4" OkControlID="Button1" >
    </asp:ModalPopupExtender>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server" ValidationGroup="Test"
ErrorMessage="TextBox2 should not be blank" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
   <!-- Keep this control at the last to hide it    -->
    <asp:Button ID="Button2" runat="server"  Text="" ValidationGroup="Test" style="margin-left:-15000px"   />

</asp:Content>
 
Share this answer
 
Comments
_Ashish 28-Feb-11 12:35pm    
Good Example! get 5
If I understood the problem...

theres one way is to use two buttons.
1. Show Modal Popup( make it "display:none;" )
2. Show Report

On Click of 'show report' Validate accordingly and if input is valid, programatically click on 'show Modal Popup' button.
 
Share this answer
 
You must be showing your work in progress image on clicking of Show Report button. So you validate the input control from javascript before showing the work in progress image. You can validate by calling a inbulit function Page_ClientValidate() , if you are using any validation group then pass it in the function.
For details about validators, you can have a look at one of my articles Click here
 
Share this answer
 
Comments
[no name] 27-Feb-11 5:39am    
I am using Validation controll

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900