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

RadTextBox Set label client side

1 Answer 325 Views
Input
This is a migrated thread and some comments may be shown as answers.
Paul
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" > 
 
</telerik:RadTextBox> 
 

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');  
    txtUrlInput.set_value("")  
 
//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
0
Dimo
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" />
<title>RadControls</title>
</head>
<body>
<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;
}
 
</script>
  
</form>
</body>
</html>


Sincerely yours,
Dimo
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
Tags
Input
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or