Hi
I'm trying to use jQuery with a Radtextbox, I can read the text but I can't change it
This works fine to read the text:
alert($telerik.$('#RadTextBox1').val())
but this don't:
$telerik.$('#RadTextBox1').val('My text')
How can I change Radtextbox1 text?
Regards
I'm trying to use jQuery with a Radtextbox, I can read the text but I can't change it
This works fine to read the text:
alert($telerik.$('#RadTextBox1').val())
but this don't:
$telerik.$('#RadTextBox1').val('My text')
How can I change Radtextbox1 text?
Regards
7 Answers, 1 is accepted
0
Hello Quim,
The proper JQuery syntax to set or retrieve the RadTextBox value should be as follows:
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The proper JQuery syntax to set or retrieve the RadTextBox value should be as follows:
alert($telerik.$(
'#RadTextBox1_text').val());
$telerik.$('#RadTextBox1_text').val('My text')
Here is a simple example for further reference:
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
</
Scripts
>
</
asp:ScriptManager
>
<
script
type
=
"text/javascript"
>
function GetSetValue() {
alert($telerik.$('#RadTextBox1_text').val());
$telerik.$('#RadTextBox1_text').val('My text')
}
</
script
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
/>
<
input
type
=
"button"
value
=
"Get/Set textbox value"
onclick
=
"GetSetValue()"
/>
Best regards,
Sebastian
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Guillaume
Top achievements
Rank 1
answered on 07 Jan 2010, 12:05 PM
Just to go further :
I'm trying to set value for all radnumerictextbox contained in a specific div, using Jquery.
I'm currently using this, which works :
I'm just wondering : is this the best way to do it ?(all the help i can found is based on Id selection, which i don't want to use)
I'm trying to set value for all radnumerictextbox contained in a specific div, using Jquery.
I'm currently using this, which works :
$telerik.$(divId + "> .RadInput > .riTextBox").val(''); |
I'm just wondering : is this the best way to do it ?(all the help i can found is based on Id selection, which i don't want to use)
0
Hello Guillaume,
The proposed approach will actually not work. It will set/clear the textbox content, which the user sees, but will not modify the actual RadTextBox value and it will be restored on the next textbox focus.
You need to use the ID approach and what's more, you must set the value twice for each RadTextBox instance:
Javascript
// visible textbox, which holds the formatted value
$telerik.$('#RadTextBox1_text').val('My text');
// hidden textbox, which holds the actual value
$telerik.$('#RadTextBox1').val('My text');
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The proposed approach will actually not work. It will set/clear the textbox content, which the user sees, but will not modify the actual RadTextBox value and it will be restored on the next textbox focus.
You need to use the ID approach and what's more, you must set the value twice for each RadTextBox instance:
Javascript
// visible textbox, which holds the formatted value
$telerik.$('#RadTextBox1_text').val('My text');
// hidden textbox, which holds the actual value
$telerik.$('#RadTextBox1').val('My text');
Sincerely yours,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Guillaume
Top achievements
Rank 1
answered on 07 Jan 2010, 12:43 PM
Yes, it does not work :(
But I don't want to use the ID approach. I want to be able to reuse my function with only one parameter (the container div id).
So, i just added this line to the previous one, as you shown me :
$telerik.$(divId + "> .RadInput > .rdfd_").val('');
and it seems to works (till you tell me it does not :) )
now, I just need to be able to enable/disable a textbox on an onclick event on its specific checkbox
Thanks,
Guillaume
But I don't want to use the ID approach. I want to be able to reuse my function with only one parameter (the container div id).
So, i just added this line to the previous one, as you shown me :
$telerik.$(divId + "> .RadInput > .rdfd_").val('');
and it seems to works (till you tell me it does not :) )
now, I just need to be able to enable/disable a textbox on an onclick event on its specific checkbox
Thanks,
Guillaume
0
Hello,
Well, you can use that approach if you are happy with it, but note that rdfd_ is an undocumented CSS class used for internal purposes and we don't guarantee that we will not change it in the future (not very likely, but I am notifying you just in case).
Not sure whether your last sentence is a question or not.
Regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Well, you can use that approach if you are happy with it, but note that rdfd_ is an undocumented CSS class used for internal purposes and we don't guarantee that we will not change it in the future (not very likely, but I am notifying you just in case).
Not sure whether your last sentence is a question or not.
Regards,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Guillaume
Top achievements
Rank 1
answered on 07 Jan 2010, 01:42 PM
Thanks for the warning. That's why I was posting here.
I think you should look at so that there's an easier/safer way to select telerik objects with jquery without using id.
As for my my last sentence, it was kind of a question. I have a checkbox which should enable/disable a radnumerictextbox when clicked.
here is my solution (which seems to work)
I'm calling this function by : onclick="EnableDisableTxt(this.id);"
(using onclick means that (i believe) i could not use a <%= myradId.ClientId)
Thanks again
Guillaume
I think you should look at so that there's an easier/safer way to select telerik objects with jquery without using id.
As for my my last sentence, it was kind of a question. I have a checkbox which should enable/disable a radnumerictextbox when clicked.
here is my solution (which seems to work)
function EnableDisableTxt(chkId) { |
var wrapperId = $("#" + chkId + " ~.RadInput")[0].id; //get the wrapper (first sibling) |
var txtid = wrapperId.replace("_wrapper", ""); // find the objectid |
if ($("#" + chkId).is(':checked')) { |
$find(txtid).enable(); |
} |
else { |
$find(txtid).disable(); |
} |
} |
I'm calling this function by : onclick="EnableDisableTxt(this.id);"
(using onclick means that (i believe) i could not use a <%= myradId.ClientId)
Thanks again
Guillaume
0
Hello,
As far as I can see, the JS code for enabling/disabling looks OK.
The RadControls' HTML ouput is more complex than the HTML output of the corresponding asp controls, so it is not always possible to allow direct manual manipulation of the RadControls' properties.
Best wishes,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
As far as I can see, the JS code for enabling/disabling looks OK.
The RadControls' HTML ouput is more complex than the HTML output of the corresponding asp controls, so it is not always possible to allow direct manual manipulation of the RadControls' properties.
Best wishes,
Dimo
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.