Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Input > A Javascript Q

Not answered A Javascript Q

Feed from this thread
  • Shan GuoTao avatar

    Posted on Mar 4, 2010 (permalink)

    I want Insert a radInput on client-side, also can insert the other radcontrols on client-side, How?
    help...
    thank you!

    Reply

  • Posted on Mar 4, 2010 (permalink)

    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.

    Reply

  • Scott R avatar

    Posted on Sep 17, 2010 (permalink)

    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?

    Reply

  • Scott R avatar

    Posted on Sep 17, 2010 (permalink)

    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">
      
    <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>

    Reply

  • Q1 Webinar Week

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Input > A Javascript Q
Related resources for "A Javascript Q"

ASP.NET Input Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]