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:
User Control Page_load Event:
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 |