AUTHOR: Veselina Raykova
DATE POSTED: November 24, 2018
The client-side object of a control is not created when its Visible=”False” property is set, thus any client-side logic executed when the page is loaded will not affect the control (e.g., built-in functions overrides). There are several ways in which this scenario can be handled, depending mainly on the moment when the control is shown (Post Back or partial AJAX update).
The OnClientLoad event of each control inside the UI for ASP.NET AJAX suite is triggered when the client-side object of the control is created. With that said, the logic placed inside the handler of the Client load event of a hidden control will be executed immediate after the control is shown.
For example:
<
asp:Panel
ID
=
"HiddenWrapper"
runat
"server"
Visible
"false"
>
telerik:RadEditor
"RadEditor1"
OnClientLoad
"onLoad"
></
</
script
type
"text/javascript"
function onLoad(editor, args) {
alert("The client-object of RadEditor is created.");
}
protected
void
Btn1_Click(
object
sender, EventArgs e)
{
HiddenWrapper.Visible =
true
;
When the script is placed inside an initially hidden container, it also will be executed once the container is shown. If you are changing the visibility of the control on full PostBack, adding the script directly inside the hidden panel would suffice:
telerik:RadButton
"Btn1"
Text
"Show"
AutoPostBack
"true"
OnClick
"Btn1_Click"
Telerik.Web.UI.RadEditor.prototype._onKeyDown = function () { alert(1); };
In case you want to wrap the script inside a container, that will be shown on a AJAX call, though, you will need to wrap the added client-side logic inside RadScriptBlock (or in some cases - RadCodeBlock):
telerik:RadAjaxManager
"RadAjaxManager1"
AjaxSettings
telerik:AjaxSetting
AjaxControlID
UpdatedControls
telerik:AjaxUpdatedControl
ControlID
/>
telerik:RadScriptBlock
RadCodeBlock and RadScriptBlock
Resources Buy Try