This is a migrated thread and some comments may be shown as answers.

get_value() not working anymore!!!

3 Answers 220 Views
Input
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 17 Sep 2012, 07:00 PM
I was running on a bit older version of telerik, but now I upgraded to the most resent version get_value() on radtextbox don't work anymore! 

<telerik:RadTextBox ID="txtRecherche" runat="server" Width="335px" style="margin: 10px 0px;"
            onkeyup="visibilite()"></telerik:RadTextBox>
 
 
 <script type="text/javascript">
        function visibilite() {          
            var chaine = $find("<%= txtRecherche.ClientID %>").get_value();
      }
 
</script>

get_value always return an empty string except when make the focus on another control and then I return in this one. 

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 18 Sep 2012, 01:23 PM
Hi Tommy,

On onkeyup event the value is still not updated, since it is not applied. The new value gets applied on blur/pressing enter or using set_value client side method.
Before applying the new value, it is considered just as DisplayValue (which can be EmptyMessage/ ErrorMessage/ Formated Text. etc.)

You can still access this text using get_textBoxValue() property during the keyup event. And you can force the control to consider this as actual value using textbox.set_value(textbox.get_textBoxValue());

Greetings,
Vasil
the Telerik team
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 their blog feed now.
0
Sophie
Top achievements
Rank 2
answered on 08 Mar 2013, 03:13 PM
Thanks Vasil.
I was having issues with this, i had to check for a textBox' s content.
On my side i can't do
someTextBox.set_value(someTextBox.get_textBoxValue());
because this will set the empty text value to the actual value. This will let my validation pass, which shouldnt.
What i did is this:
if($.trim(someTextBox.get_textBoxValue()) == '' || $.trim(someTextBox.get_textBoxValue()) == someTextBox.get_emptyMessage())
{
  alert('Empty');
}
else
{
  alert('Has content.');
}
And this works like a charm :)
0
Allen
Top achievements
Rank 2
Iron
Veteran
answered on 11 Nov 2015, 04:28 PM

THANK YOU!

 ...

...

 So I can NOW avoid passing the EmptyMessage to a popup window...

 

 

  var oInput = document.getElementById('<%= tbNotes.ClientID %>');
            var oText = "";
            var emptyMessage = $find("<%= tbNotes.ClientID %>").get_emptyMessage();
            //'value' will send the EmptyMessage if nothing has been typed, which we do not want to see in the popup, so we null it out.
            if (oInput && (oInput.value !== emptyMessage)) {
                oText = oInput.value;
            }​

Tags
Input
Asked by
Tommy
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Sophie
Top achievements
Rank 2
Allen
Top achievements
Rank 2
Iron
Veteran
Share this question
or