locked
Does a custom validator have to be used with the Validator Callout extender? RRS feed

  • Question

  • User-1833980242 posted

    I have a validator callout extender that works, it shows the callout box.  But, it does a postback.   It didn't do a post back the first time I clicked the button but it did for subsequent times.  

    I read on the AJAX site that a custom validator must be used with this for it to work.  I'm currently using this with a required field and regular expression validator.  It works, the callout appears, but it doesn't work every time with out the post back.  

    I posted this to see if there is a way to get this to work with a required field and regular expression validator, with out using a custom validator.  I'm using the newest release of the toolkit, so I thought the documentation may be old, since the call out is appearing.

    Can this work with the validators I'm using?  Do I still have to use a custom validator to get this to work with out the post back?


    Tuesday, July 6, 2010 7:01 PM

Answers

  • User-1833980242 posted

    I have the Toolkit Script Manager in my Master page.  All of the toolkit controls I add work.  The only thing that's strange is that some of the pages post back, i think to do the server side validation, after they fail client side validation.  This happens after the call out extender has appeared.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 13, 2010 5:58 AM

All replies

  • User-250973085 posted

    What control triggers the post back? There shouldn't be a post back at all, not for the two validators you are talking about (required and regular expresions).  

    Wednesday, July 7, 2010 2:10 AM
  • User-1833980242 posted

    That's the strange thing.  With out the callout extenders there is no post back.  With the callout extenders, with out custom validators, there is a post back.  This is with the regular expression and the required field validators.

    Now when I do it there is not a full post back.  The css background tiled image in the main content area flashes but the header in the master page, which is a color set with css doesn't flash.  The other day it would do a full post back, everything would flash after clicking the insert button a number of times.  

    It's the insert button that is  set to true with causes validation.  


    Wednesday, July 7, 2010 3:28 PM
  • User78336405 posted

    Hi,

    Would you please post your related code here? 

    Friday, July 9, 2010 3:03 AM
  • User-1833980242 posted

    Thaks for the help song-tian.

    If I fill in one or more of the fields it does a post back.  Then if I hit clear it doesn't do a post back with the first name when it doesn't passes validation.  The call out extenders appear for all of the fields that use them but a post back is being triggered.

     <asp:DetailsView ID="InsertCustomerDetailsView" runat="server" AutoGenerateRows="False" 
                            HeaderText="Insert Customer" DefaultMode="Insert" EnableViewState="False" 
                            DataSourceID="InsertCustomerDataSource" CssSelectorClass="DetailsView">
                <Fields>
                    <asp:TemplateField HeaderText="First Name:">
                                          
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
                            
                                <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName"  ErrorMessage="A first name is required."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic"  CssClass="validation">*</asp:RequiredFieldValidator>
                            
                                    <ajax:ValidatorCalloutExtender ID="rfv_vceFirstName" runat="server" TargetControlID="rfvFirstName"></ajax:ValidatorCalloutExtender>
                            
                                <asp:RegularExpressionValidator ID="revFirstName" runat="server" ControlToValidate="txtFirstName" ErrorMessage="The first name must be 15 alphabetical characters or less."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^(?i)[a-z\s]{1,15}$" CssClass="validation" >*</asp:RegularExpressionValidator>
                        
                            <ajax:ValidatorCalloutExtender ID="rev_vceFirstName" runat="server" TargetControlID="revFirstName"></ajax:ValidatorCalloutExtender>        
                        </InsertItemTemplate>
                      
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Last Name:">
                     
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
                            
                                <asp:RequiredFieldValidator ID="rfvLastName" runat="server" ControlToValidate="txtLastName" ErrorMessage="A last name is required."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" CssClass="validation">*</asp:RequiredFieldValidator>
                                
                                    <ajax:ValidatorCalloutExtender ID="rfv_vceLastName" runat="server" TargetControlID="rfvLastName"></ajax:ValidatorCalloutExtender>
                                
                                <asp:RegularExpressionValidator ID="revLastName" runat="server" ControlToValidate="txtLastName" ErrorMessage="The last name must be 15 alphabetical characters or less."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^(?i)[a-z\s]{1,15}$"  CssClass="validation">*</asp:RegularExpressionValidator>
                            
                                    <ajax:ValidatorCalloutExtender ID="rev_vceLastName2" runat="server" TargetControlID="revLastName"></ajax:ValidatorCalloutExtender>                    
                                
                        </InsertItemTemplate>
                      
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Address: ">
                       
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtStreetAddress" runat="server" Text='<%# Bind("StreetAddress") %>'></asp:TextBox>
                           
                                <asp:RequiredFieldValidator ID="rfvStreetAddress" runat="server" ControlToValidate="txtStreetAddress" ErrorMessage="An address is required."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" CssClass="validation">*</asp:RequiredFieldValidator>
                               
                                    <ajax:ValidatorCalloutExtender ID="rfv_vceStreetAddress" runat="server" TargetControlID="rfvStreetAddress"></ajax:ValidatorCalloutExtender>
                               
                                <asp:RegularExpressionValidator ID="revStreetAddress" runat="server" ControlToValidate="txtStreetAddress" ErrorMessage="The address must be 25 or less alphanumeric characters."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^(?i)[a-z0-9\s]{1,25}$" CssClass="validation">*</asp:RegularExpressionValidator>
                            
                                    <ajax:ValidatorCalloutExtender ID="rev_vceStreetAddress2" runat="server" TargetControlID="revStreetAddress"></ajax:ValidatorCalloutExtender>
                            
                        </InsertItemTemplate>
                       
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="City: ">
                       
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtCity" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
                            
                            <asp:RequiredFieldValidator ID="rfvCity" runat="server" ControlToValidate="txtCity" ErrorMessage="A city is required."
                                ValidationGroup="InsertValidationControls" Display="Dynamic" CssClass="validation">*</asp:RequiredFieldValidator>
                            
                                <ajax:ValidatorCalloutExtender ID="rfv_vceCity" runat="server" TargetControlID="rfvCity"></ajax:ValidatorCalloutExtender>
                            
                            <asp:RegularExpressionValidator ID="revCity" runat="server" ControlToValidate="txtCity" ErrorMessage="The city must be 20 or less alphabetic characters."
                                ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^(?i)[a-z\s]{1,20}$" CssClass="validation">*</asp:RegularExpressionValidator>
                        
                                 <ajax:ValidatorCalloutExtender ID="rev_vceCity" runat="server" TargetControlID="revCity"></ajax:ValidatorCalloutExtender>
                            
                        </InsertItemTemplate>
                       
                    </asp:TemplateField>
                   
                    <asp:TemplateField HeaderText="State: ">
                       
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtState" runat="server" Text='<%# Bind("CustState") %>'></asp:TextBox>
                            
                            <asp:RequiredFieldValidator ID="rfvState" runat="server" ControlToValidate="txtState" ErrorMessage="A state is required."
                                ValidationGroup="InsertValidationControls" Display="Dynamic" CssClass="validation">*</asp:RequiredFieldValidator>
                            
                                <ajax:ValidatorCalloutExtender ID="rfv_vceState" runat="server" TargetControlID="rfvState"></ajax:ValidatorCalloutExtender>
                            
                            <asp:RegularExpressionValidator ID="revState" runat="server" ControlToValidate="txtState" ErrorMessage="The state must be a two letter abbreviation"
                                ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^(?i)[a-z]{2}$" CssClass="validation">*</asp:RegularExpressionValidator>
                        
                                <ajax:ValidatorCalloutExtender ID="rev_vceState" runat="server" TargetControlID="revState"></ajax:ValidatorCalloutExtender>
                                
                        </InsertItemTemplate>
                        
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Zip: ">
                       
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtZip" runat="server" Text='<%# Bind("Zip") %>'></asp:TextBox>
                            
                            <asp:RequiredFieldValidator ID="rfvZip" runat="server" ControlToValidate="txtZip" ErrorMessage="A zip code is required."
                                ValidationGroup="InsertValidationControls" Display="Dynamic" CssClass="validation">*</asp:RequiredFieldValidator>
                            
                                <ajax:ValidatorCalloutExtender ID="rfv_vceZip" runat="server" TargetControlID="rfvZip"></ajax:ValidatorCalloutExtender>
                            
                            <asp:RegularExpressionValidator ID="revZip" runat="server" ControlToValidate="txtZip" ErrorMessage="The zip code must be 5 numbers."
                                ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^([0-9]{5})$" CssClass="validation">*</asp:RegularExpressionValidator>
                        
                                <ajax:ValidatorCalloutExtender ID="rev_vceZip" runat="server" TargetControlID="revZip"></ajax:ValidatorCalloutExtender>
                        
                        </InsertItemTemplate>
                       
                    </asp:TemplateField>
                    
                    <asp:TemplateField HeaderText="Phone 1: ">
                        
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtPhone1" runat="server" Text='<%# Bind("CustPhone1") %>'></asp:TextBox>
                                                    
                                <asp:RequiredFieldValidator ID="rfvPhone1" runat="server" ControlToValidate="txtPhone1" ErrorMessage="A primary phone number is required."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" CssClass="validation">*</asp:RequiredFieldValidator>
                                
                                    <ajax:ValidatorCalloutExtender ID="rfv_vcePhone1" runat="server" TargetControlID="rfvPhone1"></ajax:ValidatorCalloutExtender>
                                
                                <asp:RegularExpressionValidator ID="revPhone1" runat="server" ControlToValidate="txtPhone1" ErrorMessage="The primary phone number must be in the (###)###-#### format."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^\(([0-9]{3})\)([0-9]{3})[-]([0-9]{4})$" CssClass="validation">*</asp:RegularExpressionValidator>
                           
                                    <ajax:ValidatorCalloutExtender ID="rev_vcePhone1" runat="server" TargetControlID="revPhone1"></ajax:ValidatorCalloutExtender>
                           
                        </InsertItemTemplate>
                        
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Phone 2: ">
                        
                        <InsertItemTemplate>
                        
                            <asp:TextBox ID="txtPhone2" runat="server" Text='<%# Bind("CustPhone2") %>'></asp:TextBox>
                            
                                <asp:RegularExpressionValidator ID="revPhone2" runat="server" ControlToValidate="txtPhone2" ErrorMessage="The secondary phone number must be in the (###)###-#### format."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^\(([0-9]{3})\)([0-9]{3})[-]([0-9]{4})$" CssClass="validation">*</asp:RegularExpressionValidator>
                                
                                    <ajax:ValidatorCalloutExtender ID="rev_vcePhone2" runat="server" TargetControlID="revPhone2"></ajax:ValidatorCalloutExtender>
                                
                                <asp:CompareValidator ID="cvPhone2" runat="server" ControlToCompare="txtPhone2" ControlToValidate="txtPhone1" ErrorMessage="The primary and secondary phone numbers can't be the same."
                                    ValidationGroup="InsertValidationControls" Operator="NotEqual" Display="Dynamic" CssClass="validation">*</asp:CompareValidator>
                                            
                                    <ajax:ValidatorCalloutExtender ID="cv_vcePhone2" runat="server" TargetControlID="cvPhone2"></ajax:ValidatorCalloutExtender>       
                                     
                        </InsertItemTemplate>
                       
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email: ">
                       
                        <InsertItemTemplate>
                            <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                            
                                <asp:RegularExpressionValidator ID="revEmail" runat="server" ControlToValidate="txtEmail" ErrorMessage="The email address must be in the username@domainname format."
                                    ValidationGroup="InsertValidationControls" Display="Dynamic" ValidationExpression="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$" CssClass="validation">*</asp:RegularExpressionValidator>
                            
                                    <ajax:ValidatorCalloutExtender ID="rev_vceEmail" runat="server" TargetControlID="revEmail"></ajax:ValidatorCalloutExtender>    
                        
                        </InsertItemTemplate>
                        
                    </asp:TemplateField>
                </Fields>
                
                <FooterTemplate>
                
                    <asp:Button ID="btnInsert"  runat="server" Text="Insert" CommandName="Insert" ValidationGroup="InsertValidationControls" CausesValidation="true" />
                    <asp:Button ID="btnClear"   runat="server" Text="Clear" OnClick="btnClear_OnClick" CausesValidation="false"/>
                
                </FooterTemplate>
                           
        </asp:DetailsView>




    Saturday, July 10, 2010 10:41 AM
  • User78336405 posted

    Hi,

    Do you has other javascript to do that? I don't find any error in your code. 

    Monday, July 12, 2010 1:56 AM
  • User-1833980242 posted

    I don't have any other js.  The control toolkit is the only javascript on the page.

    Monday, July 12, 2010 9:26 PM
  • User78336405 posted

    Hi,

    I want to confirm that you are including <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/> in your code.

    Monday, July 12, 2010 10:02 PM
  • User-1833980242 posted

    I have the Toolkit Script Manager in my Master page.  All of the toolkit controls I add work.  The only thing that's strange is that some of the pages post back, i think to do the server side validation, after they fail client side validation.  This happens after the call out extender has appeared.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 13, 2010 5:58 AM