Radtextbox select text not working in panel

4 posts, 1 answers
  1. Mark
    Mark avatar
    36 posts
    Member since:
    Mar 2014

    Posted 19 Sep 2014 Link to this post

    Hello forum

    I hope you can help me out on this problem.

    I have a radtextbox in which I want to select part of the text using client .selectText.

    I build the client function and it works fine.

    Now I want to fire the clientfunction from server-side , so i implement a "ScriptManager.RegisterStartupScript" and everything is still OK.

    Then I wrap it all in radajaxpanel, whereafter my server functions fire ok , but now cant detect my radtextbox.
    (  my clientbutton still runs fine.)


    How do I call my clientscript correct from serverside, to be able to still detect my radtextbox?

    Regards
    Mark

    my base code is: 

       <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager> 
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">  
        <telerik:RadScriptBlock ID="myscriptblock" runat="server">      
            <script type="text/javascript">

         function test() {

             var tb = $find("mytxt");
             alert(tb);          
             tb.selectText(3, 6);
             return false;
          
         }
        
            </script>
        </telerik:RadScriptBlock>
             <telerik:RadTextBox ID="mytxt" ClientIDMode="Static" Runat="server"  Text="1 2 3 4 5 6 7 8 9" >
             </telerik:RadTextBox>
             <button runat="server" id="mybutton" onclick="test();return false;">findpos</button>         
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />   
        </telerik:RadAjaxPanel>
     </form>

    cs:----------------------------------------------------------------------------------------
     protected void Button1_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "eScript", "test();", true); 
        }














  2. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 23 Sep 2014 Link to this post

    Hello Mark,

    Try registering the client script through the Page like this:
    protected void Button1_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "eScript", "test();", true);
        }
     
    and see if this helps.

    Regards,
    Maria Ilieva
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    36 posts
    Member since:
    Mar 2014

    Posted 23 Sep 2014 in reply to Maria Ilieva Link to this post

    Im afraid it doesnt help either.

    Have tried registering through various objs (page,ajaxpanel,this)
    No luck; mytxt control still remains null in the clientfunction, when called by startupscript.

  5. Mark
    Mark avatar
    36 posts
    Member since:
    Mar 2014

    Posted 24 Sep 2014 Link to this post

    Solution found

    Thanks to Princy's  post  ( here )

    Instead of using startupscript I use radtextbox's clientevent onload to fire the script.

     protected void Button1_Click(object sender, EventArgs e)
        {
           mytxt.ClientEvents.OnLoad = "test";
        }

    Simple :) 
       
Back to Top