Combobox causes validation when EnableLoadOnDemand

10 posts, 0 answers
  1. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 17 Feb 2009 Link to this post

    I've got a combobox with EnableLoadOnDemand turned on and ShowMoreResultsBox as true.  When I click on the combobox or click to show more results, our validation code gets called.  I've tried setting CausesValidation to false on the combobox, but this does not have any effect.  What can I do?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Feb 2009 Link to this post

    Hi Jes,

    I tried the scenario of RadComboBox with LoadOnDeamnd set to True and using Validator for RadComboBox, and found that its working fine for me. I am not getting the validation when clicking the ShowMoreResults or when clicking the RadComboBox. Could you please provide some additional information about the setup which you tried?

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 19 Feb 2009 Link to this post

    We have a RadComboBox like this...
        <telerik:RadComboBox ID="ddlTelerik" runat="server" EnableLoadOnDemand="true" CausesValidation="false"
             
        </telerik:RadComboBox> 

    and a CustomValidator as this...
        <asp:CustomValidator runat="server" ErrorMessage="WOO" OnServerValidate="txtTest_ServerValidate3"></asp:CustomValidator> 
     

    our CustomValidator method is...
      Protected Sub txtTest_ServerValidate3(ByVal source As ObjectByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) 
     
     
        End Sub 

    I've put a breakpoint on the CustomValidator method.  When I click on the radcombobox, the breakpoint is hit.
  5. kmccusker
    kmccusker avatar
    11 posts
    Member since:
    Sep 2006

    Posted 19 Feb 2009 Link to this post

    Hi,

    Would setting the ValidationGroup property on the controls that need to be validated by the custom validator (and the validator itself) help?
  6. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 19 Feb 2009 Link to this post

    No, this does not make a difference.  I've put them in different validation groups, the same validation groups, no validation groups, and it always still fires. 
  7. kmccusker
    kmccusker avatar
    11 posts
    Member since:
    Sep 2006

    Posted 19 Feb 2009 Link to this post

    I haven't used custom validators a whole lot, but what I do know about them is:
     
    • if you leave the ControlToValidate property blank, the server validation function will fire once per server round trip
    • if ControlToValidate is set, the server event will only fire if the control it's validating has a value

    The LoadOnDemand and ShowMoreResultsBox both fire the ItemsRequested server side event. Each time this event is fired, your server side validation event is also being fired. I'm not sure what I can suggest. Hopefully what I wrote here can help you think of a workaround for your validation.

    I hope this helps,

    Kevin

  8. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 19 Feb 2009 Link to this post

    If I set CausesValidation to false on the combobox, shouldn't the validation NOT fire though?
  9. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Feb 2009 Link to this post

    Hello Jes,

    In the attached page the ServerValidate event did not fire at my side as I tested with Telerik.Web.UI v2008.3.1314.

    Could you have a look at the page and modify it so that the issue appears?

    All the best,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Jes
    Jes avatar
    23 posts
    Member since:
    Feb 2009

    Posted 24 Feb 2009 Link to this post

    Not sure how to attach files, but here is the aspx file

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!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>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server"
            <asp:ScriptManager ID="ScriptManager1" runat="server"
            </asp:ScriptManager> 
            <div> 
     
                     
                <asp:CustomValidator runat="server" EnableClientScript="False"  
                    ErrorMessage="This is an error" onservervalidate="Unnamed1_ServerValidate"></asp:CustomValidator> 
                <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" CausesValidation="false"
                </telerik:RadComboBox> 
                <br /> 
                <asp:DropDownList ID="DropDownList1" runat="server"
                    <asp:ListItem Value="1">One</asp:ListItem> 
                    <asp:ListItem Value="2">Two</asp:ListItem> 
                    <asp:ListItem Value="3">Three</asp:ListItem> 
                </asp:DropDownList> 
                <br /> 
                <br /> 
                Selected RadCombo Value = 
                <asp:Label ID="Label1" runat="server" Text="-"></asp:Label> 
                <br /> 
                Selected DropDown Value = 
                <asp:Label ID="Label2" runat="server" Text="-"></asp:Label> 
                <br /> 
                <br /> 
                <asp:Button ID="Button1" runat="server" Text="Postback Try" /> 
                <br /> 
                <asp:Button ID="Button2" runat="server" Text="Transfer to Google" OnClick="Button2_Click" /> 
                 
     
            </div> 
        </form> 
    </body> 
    </html> 
     
    and here is the .cs file

    using System; 
    using System.Web.UI; 
     
    using Telerik.Web.UI; 
     
    public partial class Default : Page 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            if (IsPostBack) 
            { 
                Label1.Text = RadComboBox1.SelectedValue; 
                Label2.Text = DropDownList1.SelectedValue; 
            } 
        } 
     
        protected void Button2_Click(object sender, EventArgs e) 
        { 
            Response.Redirect("http://www.google.com"); 
        } 
        protected void Unnamed1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) 
        { 
            args.IsValid = false
        } 

    If you breakpoint on the server validate method, it is fired every time, even with CausesValidation="false"
  11. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 27 Feb 2009 Link to this post

    Hi Jes,

    Thank you for providing the code.

    As I test I compared the behavior of RadComboBox to that of the classic TreeView control.

    If you put a classic ASP.NET TreeView which loads its Nodes via AJAX callbacks and expand a Node, the ServerValidate method still fires. This leads to the conclusion that this behavior is inherent to ASP.NET.

    In this case, I suggest you put a check for !Page.IsCallback in the ServerValidate event handler to distinguish normal from AJAX (which are the invalid ones) cases.

    Should you have any further questions, please feel free to contact us again.

    All the best,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017