+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / RequiredFieldValidator is not working in Search Control in sitefinity

RequiredFieldValidator is not working in Search Control in sitefinity

2 posts, 0 answered
  1. Pravat
    Pravat avatar
    59 posts
    Registered:
    22 Jun 2010
    24 Feb 2011
    Link to this post

    Hi, guys. I have create a custom search control in sitefinity  ~/Sitefinity/ControlTemplates/Search/CustomSearchBox.ascx folder and Configure the control. This control have a RequiredFieldValidator  validator control. when i am running the page and press search button without entering any character it is taking me to search result page. My problem is that it should not take me to search page. it should show me the message  "Please enter the search string". Below is my code. Please help me as soon as possible.

    Thanks & Regards,
    Pravat sharma
     

    <

     

    asp:Panel ID="pnlSearch" CssClass="right toplinks" runat="server" DefaultButton="searchButton">

     

     

    <asp:TextBox ID="queryText" runat="server" ValidationGroup="Search" CssClass="searchbox"></asp:TextBox>

     

     

    <asp:LinkButton ID="searchButton" runat="server" class="btnsm" ValidationGroup="Search" Text="Search" /><br />

     

     

    <asp:RequiredFieldValidator ID="rfvSearch" ControlToValidate="queryText" runat="server"

     

     

    Display="Dynamic" ErrorMessage="Please enter the search string" ValidationGroup="Search"></asp:RequiredFieldValidator>

     

     

    </

     

    asp:Panel>

     

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    30 Sep 2016
    24 Feb 2011
    Link to this post
    Hi Pravat,

    You can replace the TextBox with RadTextBox control which supports validation out of the box. In this case you will validate the text box. To stop the post back of the button you can use client side validation with custom validation for the TextBox value.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
2 posts, 0 answered