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

UserControl inside PanelItem and Javascript

2 Answers 87 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Sunny
Top achievements
Rank 1
Sunny asked on 27 Aug 2009, 10:49 PM
Hi,

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.

UserControl:

<%@ 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%">  
    <tr>  
        <td>  
        <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" />  
        </td>  
    </tr>  
</table> 

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 = ''; ") 
        script1.AppendLine("</script>") 
 
        '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 Answers, 1 is accepted

Sort by
0
Sunny
Top achievements
Rank 1
answered on 28 Aug 2009, 03:23 PM
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.Items(0).Controls.Add(uControl) 
        RadPanelItem11.Expanded = True 

Any ideas??



0
Paul
Telerik team
answered on 01 Sep 2009, 01:55 PM
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.

Regards,
Paul
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.
Tags
PanelBar
Asked by
Sunny
Top achievements
Rank 1
Answers by
Sunny
Top achievements
Rank 1
Paul
Telerik team
Share this question
or