Shan GuoTao
Top achievements
Rank 1
Shan GuoTao
asked on 04 Mar 2010, 06:44 AM
I want Insert a radInput on client-side, also can insert the other radcontrols on client-side, How?
help...
thank you!
help...
thank you!
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 04 Mar 2010, 08:02 AM
Hello Shan,
As far as I know, creating controls from client side is not possible. Instead you can add declaratively and set the visibility of the control from client side as per requirement.
You can use the set_visible() method to show/hide the control from client side.
-Shinu.
As far as I know, creating controls from client side is not possible. Instead you can add declaratively and set the visibility of the control from client side as per requirement.
You can use the set_visible() method to show/hide the control from client side.
-Shinu.
0
Scott R
Top achievements
Rank 1
answered on 17 Sep 2010, 04:41 PM
I have spent a little time trying to figure if it is possible to create a RadTextBox on the client using javascript too. As far as I can tell, Shinu's answer of creating the controls on the server then showing/hiding them on the client is the only way of emulating this behavior. The problem is that I have to create a LOT of controls on the server and send all of them to the client just in case the user decides to use them (usually they will not). This dramatically increases the page size as well as imposing a hard limit on the number of controls the user can view (I've chosen 25, but what if they need 30?).
I realize that the RadTextBox is more than just a simple HTML control and that it may be very difficult to implement functionality to create it using javascript. I seem to recall seeing a javascript "clone" method at one time but I can't find it now. Cloning another control would be a good option too.
The only other thing I can think of is maybe there is a way to add controls to the RadInputManager using javascript? I can create a simple HTML input control using javascript without any problem, is it possible to then add that control to the RadInputManager using javascript? I don't see a way to do it, but if I could that would solve my problem as well.
Anyone have any ideas?
I realize that the RadTextBox is more than just a simple HTML control and that it may be very difficult to implement functionality to create it using javascript. I seem to recall seeing a javascript "clone" method at one time but I can't find it now. Cloning another control would be a good option too.
The only other thing I can think of is maybe there is a way to add controls to the RadInputManager using javascript? I can create a simple HTML input control using javascript without any problem, is it possible to then add that control to the RadInputManager using javascript? I don't see a way to do it, but if I could that would solve my problem as well.
Anyone have any ideas?
0
Scott R
Top achievements
Rank 1
answered on 17 Sep 2010, 06:43 PM
This isn't exactly what we're after, but it's close. Maybe this will help someone else:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
script
type
=
"text/javascript"
language
=
"javascript"
>
function CreateTextBox() {
// Create new text box.
var tb = document.createElement('input');
tb.type = 'text';
tb.name = 'tbTest';
tb.id = 'tbTest';
tb.size = 40;
// Add it to the document.
var idiv = document.getElementById('InputDiv');
idiv.appendChild(tb);
// Add it to the RadInputManager.
var imgr = $find('<%= RadInputManager1.ClientID %>');
imgr.get_numericTextBoxSettings()[0].addTargetInput(tb.id);
}
</
script
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
id
=
"InputDiv"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
p
>
<
input
type
=
"button"
onclick
=
"javascript:CreateTextBox();"
value
=
"Create Text Box"
/>
</
p
>
<
telerik:RadInputManager
ID
=
"RadInputManager1"
runat
=
"server"
>
<
telerik:NumericTextBoxSetting
BehaviorID
=
"NumericTextBoxSetting1" /
>
</
telerik:RadInputManager
>
</
div
>
</
form
>
</
body
>
</
html
>