How to set Invalid Style on server side

4 posts, 0 answers
  1. Li Zhou
    Li Zhou avatar
    23 posts
    Member since:
    Dec 2003

    Posted 24 Jun 2010 Link to this post

    Can someone help me how t set invalid style in server side.  My code as as following.  When validate through client side, textbox style is set to invalid style(CssClass="InvalidTextBox") if validation fails.  Similarlly I want to do the validation in server side just in case client side validation does not go through.  How to set to Invalid style in server side ?



    telerik:RadTextbox ID="Email" runat="server">




    EmptyMessageStyle CssClass="EmptyTextBox" />






        <EnabledStyle CssClass="EnabledTextBox" />






        <FocusedStyle CssClass="FocusedTextBox" />






        <HoveredStyle CssClass="HoveredTextBox" />






        <InvalidStyle CssClass="InvalidTextBox" />






    asp:CustomValidator runat="server" EnableClientScript="true" controltovalidate="Email" id="ev" ClientValidationFunction="ClientValidate" OnServerValidate="ServerValidate" />




    ClientValidate(sender, args)



         var email = $find("<%= email.ClientID %>");



            if (! validate(email.get_value())) 


                email._invalid =




                args.IsValid =






    protected void ServerValidate(object source, ServerValidateEventArgs args)




        args.IsValid = validate(email.Text);



        if (!args.IsValid)




            //how to set invalid style for email RadTextBox ????





  2. Dimo
    Dimo avatar
    8456 posts

    Posted 28 Jun 2010 Link to this post

    Hi Li Zhou,

    Probably the easiest way to achieve the desired behavior is to use an additional asp:HiddenField control to pass a flag to the client, then use the RadTextBox' Load client event, check the flag value, set the _invalid client property and execute updateCssClass(), as in the ClientValidate function.

    Afterwards, the _invalid property value can be changed in the ValueChanged RadTextBox client event handler.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Rafal
    Rafal avatar
    27 posts
    Member since:
    Dec 2007

    Posted 10 May 2011 Link to this post

    Can this please be added to the back end at some point? it should have been there to begin with....
  4. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 13 May 2011 Link to this post

    Hello Rafal,

    Adding such functionality could introduce a lot of conflicts with custom client-side validation of the controls or validation from other parts of the page . There are many possible scenarios all of which could hardly be handled in order to implement such feature. Currently a scenario requiring not that much custom code does not outweigh the effort and limitations of trying to make this a built-in feature.

    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top