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

RadTextBox Set label client side

1 Answer 495 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Paul asked on 29 Jun 2010, 02:58 PM
Is there a way to change the Label property via javascript.




<telerik:RadTextBox Width="300px" ID="txtUrl" runat="server" Label="Url: " 
EmptyMessage="please type url here" InvalidStyleDuration="100" > 

Depending on what has been selected in a combobox I want to chnage the label from Url: to something else


    var txtUrlInputID = $telerik.$("[id$='txtUrl']").attr("id");  
    var txtUrlInput = $find(txtUrlInputID);  
    txtUrlInput.set_emptyMessage('Please type Email here');  
//I would like to set label as well. I know the below does not exist but can I do it another way.  
//txtUrlInput.set_label("Email: ") 


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 01 Jul 2010, 12:17 PM
Hi Paul,

You can achieve the desired behavior like this:

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="TextBox1" runat="server" Text="Label" />
<asp:Button ID="Button1" runat="server" Text="Apply" OnClientClick="return setLabel()" />
<br /><br />
<telerik:RadTextBox ID="RadTextBox1" runat="server" Label="Label" />
<script type="text/javascript">
function setLabel()
    var tb = $find("<%= RadTextBox1.ClientID %>");
    $get(tb._wrapperElementID).getElementsByTagName("label")[0].innerHTML = $get("<%= TextBox1.ClientID %>").value;
    return false;

Sincerely yours,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question