$Find and .clear() Not Working

6 posts, 1 answers
  1. James
    James avatar
    55 posts
    Member since:
    Oct 2011

    Posted 26 May 2013 Link to this post

    Hi,

    I do like this new RadSearchBox control, but I am having a few small problems.

    First, I am having difficulty accessing the control client side.  I've used several variations of $find to no avail.  Would someone please suggest some alternative syntaxes.

    Second, once I find this control, I would like to .clear() it of its previous search text/value.  I've tried to do this on the OnClientSearch event (using sender.clear()), but no luck with that either. 

    Any suggestions?

    Jim
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 May 2013 Link to this post

    Hi,

    Please have a look into the following code i tried to access the RadSearchBox from client side and clear the content on a RadButton client click.

    ASPX:
    <telerik:RadSearchBox ID="RadSearchBox1" runat="server" DataSourceID="SqlDataSource1"
        DataTextField="ShipCity">
    </telerik:RadSearchBox>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Click" OnClientClicked="OnClientClicked">
    </telerik:RadButton>

    JavaScript:
    <script type="text/javascript">
        function OnClientClicked() {
            var searchBox = $find("<%= RadSearchBox1.ClientID %>");
            searchBox.clear();
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. James
    James avatar
    55 posts
    Member since:
    Oct 2011

    Posted 27 May 2013 Link to this post

    Shinu,

    Thanks so much.  I'm not sure why I was having trouble with this before, but it is working now.

    Thanks,

    Jim
  5. Evgeniy Ovcharenko
    Evgeniy Ovcharenko avatar
    3 posts
    Member since:
    Sep 2004

    Posted 01 Jul 2013 Link to this post

    Hello,

    I have the same issue. Here is my control definition:
    <telerik:RadSearchBox ID="RadSearchBox1" runat="server" OnClientSearch="myFilesSearch" EnableAutoComplete="False">
                     </telerik:RadSearchBox>

    and my javascript:

    function myFilesSearch(sender, args) {
                var searchBox = $find("<%= RadSearchBox1.ClientID %>");
                searchBox.clear();
            }

    $find works well, but clear() does nothing.

    Can somebody help me?
  6. Plamen
    Admin
    Plamen avatar
    2729 posts

    Posted 02 Jul 2013 Link to this post

    Hello,

     
    You have to set the value of the input element as in the code below:

    sender.get_inputElement().value = "";

    Hope this will be helpful.
    Regards,
    Plamen
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. Evgeniy Ovcharenko
    Evgeniy Ovcharenko avatar
    3 posts
    Member since:
    Sep 2004

    Posted 02 Jul 2013 Link to this post

    It works!
    Thank you
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017