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

set_value on ReadOnly RadTextBox failed?

2 Answers 193 Views
Input
This is a migrated thread and some comments may be shown as answers.
Miao Weibin
Top achievements
Rank 1
Miao Weibin asked on 26 Aug 2009, 06:28 AM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2009, 07:21 AM
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.
0
Miao Weibin
Top achievements
Rank 1
answered on 28 Aug 2009, 03:44 AM
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]); 




Tags
Input
Asked by
Miao Weibin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Miao Weibin
Top achievements
Rank 1
Share this question
or