Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rik Hodiamont 56 posts 156 karma points
    Jan 20, 2015 @ 11:46
    Rik Hodiamont
    0

    Custom validation won't fire in usercontrol

    Hi,

    I have a problem with a form. I build a form with the following code:

    <div class="form_row">
         <asp:TextBox ID="txtVoornaam" runat="server" placeholder="Voornaam" CausesValidation="true"></asp:TextBox>
         <asp:CustomValidator ID="CustomValidator3" runat="server" ForeColor="Red" ClientValidationFunction="ValidationFunction1" ValidateEmptyText="True" Display="Dynamic" ControlToValidate="txtVoornaam" ></asp:CustomValidator>
     </div>
    

    The script 'validationfunction1':

       function ValidationFunction1(source, args) {
            alert('test');
            var controlId = document.getElementById(source.controltovalidate).id;
            var control = $("#" + controlId);
            var value = control.val();
            var is_valid = value != "";
            is_valid ? control.removeClass("error") : control.addClass("error");
            args.IsValid = is_valid;
        }
    

    When I test the form on the localhost everything works fine. But when I build the solution and include it into umbraco the customvalidation doesn't work.

    I used Page.Validate(); if (Page.IsValid) on the submit click action in the code behind but that doesn't have any effect.

    I found differtent solutions but none of them works.

    Any help would be appreciated.

    Best regards, Rik

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 20, 2015 @ 11:55
    Jan Skovgaard
    0

    Hi Rik

    What version of Umbraco are you using? Just asking to figure out whether it could be an issue with Webforms since Umbraco 7 for instance runs MVC by default. So it's pretty important to know in order for people to provide qualified answers :)

    /Jan

  • Rik Hodiamont 56 posts 156 karma points
    Jan 20, 2015 @ 12:49
    Rik Hodiamont
    0

    Hi Jan,

    Thanks for your reply.

    I'm using Umbraco 7 and set webforms as default during the installation. I don't use MVC.

    Best regards, Rik

  • Rik Hodiamont 56 posts 156 karma points
    Jan 20, 2015 @ 13:53
    Rik Hodiamont
    0

    I just add the entire project to a folder on the umbraco server. I excluded the folder with the umbracoReservedPaths and the project is working fine. But when I add the usercontrol into Umbraco it doesn't. I stripped out every other code so the only thing left is the usercontrol, but it still doesn't work. 

    The problem is caused by the macro. I put the usercontrol directly into the template and it works :):

    <%@ Register Src="Vil-samba.ascx" TagPrefix="uc1" TagName="Vilsamba"  %>

    <uc1:Vilsamba runat="server" id="Vilsamba" />

    How can it be that it doesn't work with the macro? And how can I get it to work?

    Any ideas?

    Best regards, Rik 

Please Sign in or register to post replies

Write your reply to:

Draft