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

ReadOnly=true and set_value not work

1 Answer 108 Views
Input
This is a migrated thread and some comments may be shown as answers.
Rudá Cunha
Top achievements
Rank 2
Rudá Cunha asked on 29 Nov 2010, 03:35 PM
When the field is set to ReadOnly=true the set_value not work!

Enabled cannot use because the user needs access to the field to copy the information.
How do I fix this?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 29 Nov 2010, 05:52 PM
Hello Rudá Cunha,

set_value() works when a RadTextBox is readonly, however, you should know that the new value is not persisted across postbacks - this is by design and asp:TextBoxes behave the same way.

<%@ 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" />
 
<telerik:RadTextBox ID="RadTextBox1" runat="server" ReadOnly="true" Text="initial value" />
 
<asp:Button Text="set new value 1" runat="server" ID="Button1" OnClientClick="return setNewValue(1);" />
 
<asp:Button Text="set new value 2" runat="server" ID="Button2" OnClientClick="return setNewValue(2);" />
 
<asp:Button Text="get value" runat="server" ID="Button3" OnClientClick="return getValue();" />
 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
 
function setNewValue(nv)
{
    $find("<%= RadTextBox1.ClientID %>").set_value(nv);
    return false;
}
 
function getValue()
{
    alert($find("<%= RadTextBox1.ClientID %>").get_value());
    return false;
}
 
</script>
</telerik:RadCodeBlock>
 
</form>
</body>
</html>


Greetings,
Dimo
the Telerik team
Browse the vast support resources we have to jumpstart 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.
Tags
Input
Asked by
Rudá Cunha
Top achievements
Rank 2
Answers by
Dimo
Telerik team
Share this question
or