Rank: Newbie Groups: Member
Joined: 8/27/2009 Posts: 2
|
Hi,
Am trying to use a custom validation control in a dialog, but am having trouble getting it to fire, the required validation works OK but not the custom validator. Please find quick example below.
Thanks
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %> <!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 runat="server"> <title></title> <script type="text/javascript"> function val(source, args) { args.IsValid = false; alert('Test') } </script> </head> <body> <form id="form1" runat="server"> <div> <eo:Dialog ID="Dialog1" runat="server" BackColor="White" Height="216px" ClientSideOnCancel="val" Width="320px" CloseButtonUrl="00020312" ControlSkinID="None" HeaderHtml="Dialog Title"> <HeaderStyleActive CssText="background-image:url('00020311');color:black;font-family:'trebuchet ms';font-size:10pt;font-weight:bold;padding-bottom:5px;padding-left:8px;padding-right:3px;padding-top:0px;" /> <BorderImages BottomBorder="00020305" BottomLeftCorner="00020304" BottomRightCorner="00020306" LeftBorder="00020303" RightBorder="00020307" TopBorder="00020310" TopLeftCorner="00020301" TopLeftCornerBottom="00020302" TopRightCorner="00020309" TopRightCornerBottom="00020308" /> <FooterStyleActive CssText="padding-right: 4px; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; padding-top: 4px; font-family: tahoma" /> <ContentTemplate> <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Test" /> <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Textbox 1 empty!" ControlToValidate="TextBox1" ValidationGroup="Test" Text="Textbox 1 empty!"></asp:RequiredFieldValidator> <br /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Textbox 2 empty!" ValidationGroup="Test" ClientValidationFunction="val" ControlToValidate="TextBox2" ValidateEmptyText="True">Textbox 2 empty!</asp:CustomValidator> <br /><br /> <asp:ImageButton ID="ImageButton1" runat="server" ValidationGroup="Test" /> </ContentTemplate> <ContentStyleActive CssText="padding-right: 4px; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; padding-top: 4px; font-family: tahoma" /> </eo:Dialog> <a id="ViewInGoogleMaps" runat="server" href="javascript:eo_GetObject('Dialog1').show();" style="font-weight:normal;">View in Google Maps</a> </div> </form> </body> </html>
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The issue has nothing to do with the dialog. It was caused by your JavaScript function name "val". Standard ASP.NET validator code also has a local variable named "val" when it tries to call your code, which conflicts with your code. Try to rename your "val" function to something else and it should work fine.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 8/27/2009 Posts: 2
|
Thanks So it does!! That was just a qick example done at speed, changing the name did work. I now have a greater problem being I can get it to work in the example as shown but not in my original app which has a different name already!!! Nevermind, and thanks for your time.
|