ReadOnly=true and set_value not work

2 posts, 0 answers
  1. Rudá Cunha
    Rudá Cunha avatar
    56 posts
    Member since:
    Mar 2010

    Posted 29 Nov 2010 Link to this post

    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?
  2. Dimo
    Admin
    Dimo avatar
    8456 posts

    Posted 29 Nov 2010 Link to this post

    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.
Back to Top