Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Input > RadTextBox does not return correct string value, using in javascript
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered RadTextBox does not return correct string value, using in javascript

Feed from this thread
  • manoj naik avatar

    Posted on Apr 12, 2011 (permalink)

    Hey guys,

    We have used a RadTextBox in our master page for search. I want to disable a particular button based on the string present in the box or not. I have used below javascript which I call on the keyup event of the RadTextBox. However it is not returning a proper value of characters present in the RadTextbox while I am typing in it. If I enter a letter "a" it returns me nothing. But if I further type "b" then it returns me "a". So it returns my typed word - last character. Such is not the case with the normal asp textbox.
    The reason being that I am using ClientID property of the RadTextBox. It is rendered as below.
    <span id="txtSearch_wrapper" class="RadInput RadInput_Default" style="white-space:nowrap;">
            <input type="text" size="20" id="txtSearch_text" name="txtSearch_text" class="riTextBox riEnabled" onkeyup="disableSearchButton();" style="width:125px;" />
            <input id="txtSearch" name="txtSearch" class="rdfd_" style="visibility:hidden;margin:-18px 0 0 -1px;width:1px;height:1px;overflow:hidden;border:0;padding:0;" type="text" value="" />
              <input id="txtSearch_ClientState" name="txtSearch_ClientState" type="hidden" />
    </span>
    I need the "txtSearch_text" as ClientId, however the code is returning "txtSearch". Is there any way I can do that.

    function disableSearchButton() {
                var searchButton = document.getElementById("<%= txtSearch.ClientID %>");
                alert(searchButton.value);
            }
    <telerik:RadTextBox ID="txtSearch" EnableViewState="false" onkeyup="disableSearchButton();" runat="server" />

    Note: Do not worry about the getElementById() that I am using to get the reference to the search box in javascript. I am pretty much sure it is correct.

    Thanks,
    Manoj

  • Mira Mira admin's avatar

    Posted on Apr 18, 2011 (permalink)

    Hello Manoj,

    Please use the following code in order to achieve the desired functionality:
    function disableSearchButton() {
        var searchButton = $find("<%= txtSearch.ClientID %>");
        alert(searchButton.get_textBoxValue());
    }

    I hope it helps.

    Greetings,
    Mira
    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

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Input > RadTextBox does not return correct string value, using in javascript