Asked by:
ValidatorCalloutExtender + CustomValidator - It´s possible?

Question
-
User2038806734 posted
WHERE´S THE ValidatorCalloutExtender?
Portuguese Question
----------------------------------------------------
Estou tentando chamar um ValidatorCalloutExtender a partir de um CustomValidator, alguém aqui já fez isso? Isso é possível? Pois no meu exemplo abaixo isso não funciona.English Question
----------------------------------------------------
I can try to call ValidatorCalloutExtender from a CustomValidator, but it´s not work. It´s possíble? My example doesn´t work. PLEASE HELP ME!-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
teste.aspx
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="teste.aspx.cs" Inherits="teste" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 5 <html xmlns="http://www.w3.org/1999/xhtml" > 6 <head runat="server"> 7 <title>Untitled Page</title> 8 </head> 9 <body> 10 <form id="form1" runat="server"> 11 <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager> 12 <div> 13 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 14 15 <asp:CustomValidator ID="CustomValidator1" ControlToValidate="TextBox1" runat="server" ErrorMessage="weadsasdsa" OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator> 16 <ajaxToolkit:ValidatorCalloutExtender ID="ceUsuarioNome" TargetControlID="CustomValidator1" runat="server"></ajaxToolkit:ValidatorCalloutExtender> 17 18 <asp:Button ID="Button1" runat="server" Text="Button" /> 19 </div> 20 </form> 21 </body> 22 </html>
<?xml:namespace prefix = asp /><asp:Button class=st id="-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
teste.aspx.cs
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------1 using System; 2 using System.Data; 3 using System.Configuration; 4 using System.Collections; 5 using System.Web; 6 using System.Web.Security; 7 using System.Web.UI; 8 using System.Web.UI.WebControls; 9 using System.Web.UI.WebControls.WebParts; 10 using System.Web.UI.HtmlControls; 11 12 public partial class teste : System.Web.UI.Page 13 { 14 protected void Page_Load(object sender, EventArgs e) 15 { 16 17 } 18 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) 19 { 20 if(TextBox1.Text == "janis"){ 21 args.IsValid = true; 22 }else{ 23 args.IsValid = false; 24 } 25 } 26 } 27
Thursday, December 14, 2006 5:42 PM
All replies
-
User-837620913 posted
I believe, from looking at the ValidatorCallout known issues, that it only works on CustomValidators with client-side validation (i.e., JavaScript). Here's the part of the sentence:
"...will only work for custom validators which utilize client-side validation."
Sunday, December 17, 2006 8:53 PM -
User-391569626 posted
Can you show some exemple code??
I´m having this problem too.
[:(]
Tks...
See yaa!Monday, February 5, 2007 2:11 PM -
User1226477373 posted
From what I've seen, you cannot use the ValidatorCalloutExtender when the CustomValidator is using a server side validation. In this case the solution is relatively simple. Instead of using a CustomValidator, try using a RegularExpressionValidator. I've tested the following at it will work with ValidatorCalloutExtender without a postback.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" Title="Untitled Page" StylesheetTheme="SkinFile" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" Display="None" ErrorMessage="weadsasdsa" ValidationExpression="janis" /> <ajaxToolkit:ValidatorCalloutExtender ID="ceUsuarioNome" TargetControlID="RegularExpressionValidator1" runat="server" /> </div> </form> </body> </html>
Wednesday, February 21, 2007 3:58 PM -
User1226477373 posted
If you still want to use a CustomValidator, then create a ClientValidationFunction instead of a server side function. The following demonstrates an example of this.
1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" Title="Untitled Page" StylesheetTheme="SkinFile" %> 2 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 5 <html xmlns="http://www.w3.org/1999/xhtml" > 6 <head id="Head1" runat="server"> 7 <title>Untitled Page</title> 8 <script type="text/javascript"> 9 function ClientValidate(source, clientside_arguments) 10 { 11 if (clientside_arguments.Value == "janis" ) 12 { 13 clientside_arguments.IsValid = true; 14 } 15 else { clientside_arguments.IsValid = false; } 16 } 17 </script> 18 </head> 19 <body> 20 <form id="form1" runat="server"> 21 <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager> 22 <div> 23 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 24 <asp:Button ID="Button1" runat="server" Text="Button" /> 25 <asp:CustomValidator ID="CustomValidator1" runat="server" Display="None" ErrorMessage="Error" 26 ControlToValidate="TextBox1" ClientValidationFunction="ClientValidate" /> 27 <ajaxToolkit:ValidatorCalloutExtender ID="ceUsuarioNome" TargetControlID="CustomValidator1" 28 runat="server" /> 29 </div> 30 </form> 31 </body> 32 </html>
Wednesday, February 21, 2007 4:13 PM -
User-768488921 posted
or in your custom validator place a field to validate it could be any text box but validate callout needs something ,
<asp:CustomValidator ID="RCVlen2" ControlToValidate="wid3" runat="server" ErrorMessage="Adjust end widths" ClientValidationFunction="ValidateCheckBox" Display="None"></asp:CustomValidator>
<asp:ValidatorCalloutExtender ID="vcblen2C2" runat="server" TargetControlID="RCVlen2" CssClass="vcall">
Wednesday, October 10, 2012 4:13 PM -
Wednesday, October 10, 2012 11:42 PM