Textbox firing validators inside RAD Grid

2 posts, 0 answers
  1. Kishan Gandikota
    Kishan Gandikota avatar
    44 posts
    Member since:
    Sep 2009

    Posted 07 Nov 2009 Link to this post

    Hi Telerik Team,

    Product that we are developing requires RAD Grid and a text box inside the grid. What we are doing is to have a asp:Textbox with GridTemplateColumn added.

    <asp:Textbox id="txtUser" runat="server" Text='<%#Bind("UserInfo")%'  OnTextChanged="txtUser_TextChanged"/>
    <asp:RequiredFieldValidator id="revTxtUser" runat="server" ControlToValidate="txtUser" ErrorMessage="User Info is blank" />

    Please note that this textbox has a required field validator. We don't want a edititemtemplate rather a textbox pre-filled with values (UserInfo) from datasource. When user changes the text inside a textbox, my OnTextChanged event gets fired.

    We have a scenario where the data coming the datasource for UserInfo is blank. In the same page, we have a button that will do the postback. During this time, my requiredFieldValidator is not getting fired. I will also have RegularExpressionValidator with this textbox. Even this need to be fired.

    Is there any way to fire this client side validator. I tried setting ValidationGroup also. It didn't work out. Worst solution here would be to use asp:CustomValidator and do the validation at the server side. But I wan't to keep this as the last option.

    Could you please guide me on how to fire these validators? Is there a way to fire these validators?

    Kishan G K
  2. Johny
    Johny avatar
    80 posts
    Member since:
    Aug 2008

    Posted 12 Nov 2009 Link to this post

    Hi Kishan,

    If I understand your scenario correctly you want to use a RegularExpressionValidator to validate an empty TextBox on the client. In the same time you have a RequiredFieldValidator validating the same textbox that you do not want to fire. This scenario is quite strange to me. Why don't you just use the RequiredFieldValidator for empty string validation and the RegularExpressionValidator for any other purposes? In this case all you have to do is to ensure that your browser supports the client side validation.

    I hope this helps,
  3. DevCraft R3 2016 release webinar banner
Back to Top