Hi,
I have a web-usercontrol which works fine - on a normal (ajax enabled) page.
But when I place the control in a Grid's Edit FormTemplate the emitted script no longer works.
The control is only used in edit mode - and I looked around a lot here - but I could not get it to work.
By the way - the script is in the source of the page - but it is somehow ignored.
My Control renders some script in it's OnPreRender handler.
The approach is to add an "OnLoad" handler for a contained control.
Again - it works well as long as it is not in a grid.
Here is my (I tried what ever I found and could imagine) PreRender function:
To keep the things simple - I used just an alert to this script - which should alter when the script is seen by the client.
But it does nothing!!
Although the alert is there in source code!!
Being a bit frustrated - I tried the "direct approach" and changed my control to this:
The result - after I switch to edit I get an error message: "Onthisloaded" not found.
Regards
Manfred
I have a web-usercontrol which works fine - on a normal (ajax enabled) page.
But when I place the control in a Grid's Edit FormTemplate the emitted script no longer works.
The control is only used in edit mode - and I looked around a lot here - but I could not get it to work.
By the way - the script is in the source of the page - but it is somehow ignored.
My Control renders some script in it's OnPreRender handler.
The approach is to add an "OnLoad" handler for a contained control.
Again - it works well as long as it is not in a grid.
Here is my (I tried what ever I found and could imagine) PreRender function:
protected override void OnPreRender(EventArgs e) { |
string strScript="alert('Hello');"; |
base.OnPreRender(e); |
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MyBlock" + ClientID, strScript, true); |
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MyBlock1" + ClientID, strScript, true); |
RadScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MyBlock2" + ClientID, strScript, true); |
aM.ResponseScripts.Add("<script type=\"text/javascript\">\r\n" + strScript + "\r\n</script>"); |
this.Controls.Add(new LiteralControl("<script type=\"text/javascript\">\r\n" + strScript + "\r\n</script>")); |
//rtBox.ClientEvents.OnLoad = "OnLoad_" + ClientID; |
} |
But it does nothing!!
Although the alert is there in source code!!
Being a bit frustrated - I tried the "direct approach" and changed my control to this:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WSTextBox.ascx.cs" Inherits="VJF09.Classes.WSTextBox" %> |
<script type="text/javascript"> |
function OnThisloaded() { |
alert("Tet"); |
} |
</script> |
<telerik:RadTextBox runat="server" ID="rtBox" ClientEvents-OnLoad="OnThisloaded"> |
</telerik:RadTextBox> |
Regards
Manfred