UserControl inside PanelItem and Javascript

3 posts, 0 answers
  1. Sunny
    Sunny avatar
    31 posts
    Member since:
    Aug 2009

    Posted 27 Aug 2009 Link to this post


    I am dynamically adding a UserControl to RadPanelItem.

    And in UserControl I am registering some JavaScript block.(I am giving code is below)

    Problem: I can't get the javascript function to fire.
    Also, if I viewsource aspx page I can't see html code for usercontrol and javascript block.


    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="UserControl1.ascx.vb" Inherits="UserControl1" %>  
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Telerik" %>  
    <Telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" EnableEmbeddedScripts="true" ></Telerik:RadAjaxPanel>  
    <table width="100%">  
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>     
                <asp:Button ID="buttonClear" runat="server" Text="Clear" Width="46" UseSubmitBehavior="false"  
                    CausesValidation="false" OnClientClick="ClearMe();return false" />  

    User Control Page_load Event:
            Dim script1 As New StringBuilder 
            script1.AppendLine("<script language='javascript' type='text/javascript'>") 
            script1.AppendLine("    function ClearMe(){ ") 
            script1.AppendLine("        alert();") 
            script1.AppendLine("        document.getElementById(" & TextBox1.ClientID & ").value = ''; ") 
            'I tried 
        'Me.Controls.Add(New LiteralControl(clearScript.ToString())) 
            'I tried 
            'ScriptManager.RegisterStartupScript(Parent.Page, Me.GetType(), "ClearBox", script1.ToString, True) 
            'I tried 
            If Not Parent.Page.ClientScript.IsStartupScriptRegistered("ClearBox") Then 
                Parent.Page.ClientScript.RegisterStartupScript(Me.GetType(), "ClearBox", script1.ToString, True) 
            End If  
  2. Sunny
    Sunny avatar
    31 posts
    Member since:
    Aug 2009

    Posted 28 Aug 2009 Link to this post

    In the Page_Load of Default.aspx I am calling usercontrol

            Dim uControl As myUserControl = CType(Page.LoadControl("~/MyProject/UserControls/myUserControl.ascx"), myUserControl) 
            uControl.ID = "myUniID" 
            Dim RadPanelItem11 As RadPanelItem = RadPanelMain1.FindItemByValue("MYTemplateHolder") 
            RadPanelItem11.Expanded = True 

    Any ideas??

  3. Paul
    Paul avatar
    4281 posts

    Posted 01 Sep 2009 Link to this post

    Hello TelNew,

    I think it will be best if you can open a support ticket and send us a simple running project (incl. your custom skin, CSS, images, DB backup if needed and so on) demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top