set_value on ReadOnly RadTextBox failed?

3 posts, 0 answers
  1. Miao Weibin
    Miao Weibin avatar
    10 posts
    Member since:
    Jul 2008

    Posted 26 Aug 2009 Link to this post

    aspx:
    <telerik:RadTextBox runat="server" ID="rtxtUserName" ReadOnly="true"></telerik:RadTextBox>
    <input type="button" value="Assign Value" onclick="assignValue()">
    <asp:Button runat="server" ID="Button1" OnClick="Button1_OnClick"></asp:Button>
    js:

    function assignValue()
    {
    var userName = $find('<%= rtxtUserName.ClientID %>');
    userName.set_value('Thomas');
    }

    cs:

    Button1_Click
    {
    string userName = rtxtUserName.Text;
    }

    when clicking the "Assign Value" button, nothing happens on rtxtUserName if ReadOnly set to be true.



  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Aug 2009 Link to this post

    Hi Miao Weibin,

    I tried the scenario at my end and found that I can assign the textbox value from client side when it is set to ReadOnly mode but not able to retrieve the value on server side. Hence I tried setting the ReadOnly mode by accessing the textboxElement and setting its readonly property to true in OnLoad event of RadTextBox instead of setting the ReadOnly property for RadTextBox declaratively. Tryout  the code below and let me know it helps.

    aspx:
     
    <telerik:RadTextBox runat="server" ID="rtxtUserName"  > 
    <ClientEvents OnLoad="setReadOnly" /> 
    </telerik:RadTextBox> 
     
    <input type="button" value="Assign Value" onclick="assignValue()"
    <asp:Button runat="server" ID="Button3" Text="Show content" OnClick="Button1_OnClick"></asp:Button> 

    javascript:
     
    <script type="text/javascript"
    function setReadOnly() 
        var TextBox1 = $find("<%= rtxtUserName.ClientID %>"); 
        TextBox1._textBoxElement.readOnly = true
    function assignValue() 
       var userName = $find('<%= rtxtUserName.ClientID %>'); 
       userName.set_value('Thomas'); 
    </script> 

    cs:
     
    protected void Button1_OnClick(object sender, EventArgs e) 
        Response.Write(rtxtUserName.Text); 

    -Shinu.
  3. Miao Weibin
    Miao Weibin avatar
    10 posts
    Member since:
    Jul 2008

    Posted 27 Aug 2009 Link to this post

    thanks, Shinu, It does work.
    Sebastian gives another answer:
    aspx:
    <telerik:RadTextBox runat="server" ID="rtxtUserName"  > 
    </telerik:RadTextBox> 
     
    <input type="button" value="Assign Value" onclick="assignValue()"
    <asp:Button runat="server" ID="Button3" Text="Show content" OnClick="Button1_OnClick"></asp:Button> 

    function assignValue() 
       var userName = $find('<%= rtxtUserName.ClientID %>'); 
       userName.set_value('Thomas'); 

    cs:
    protected void Button1_OnClick(object sender, EventArgs e) 
        Response.Write(Request[rtxtUserName.UniqueID]); 




Back to Top