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

Radtextbox select text not working in panel

3 Answers 104 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 19 Sep 2014, 09:34 AM
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); 
    }














3 Answers, 1 is accepted

Sort by
0
Accepted
Maria Ilieva
Telerik team
answered on 23 Sep 2014, 12:50 PM
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.

 
0
Mark
Top achievements
Rank 1
answered on 23 Sep 2014, 01:09 PM
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.

0
Mark
Top achievements
Rank 1
answered on 24 Sep 2014, 08:47 AM
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 :) 
   
Tags
Ajax
Asked by
Mark
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Mark
Top achievements
Rank 1
Share this question
or