Raised after all scripts have been loaded and all objects in the application that are created by using
$create are initialized. The load event is raised for all postbacks to the server, which includes asynchronous postbacks.
If you are a page developer, you can create a function that has the name
pageLoad, which automatically provides a handler for the load event. The
pageLoad handler is called after any handlers that have been added to the load event by the add_load method.
The load event takes an eventargs parameter, which is an
Sys.ApplicationLoadEventArgs object. You can use the event arguments to determine whether the page is being refreshed as a result of a partial-page update and what components were created since the previous load event was raised.
agentZuluka
Member
1 Points
5 Posts
Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 01:57 PM|LINK
Hi!
I was trying AjaxControlToolkit and find it very useful, so thanks for that!
Unfortunately I have one trouble with AjaxControlToolkit.HTMLEditor.
I need to put some text in editor after page was loaded (in JavaScript)
Current it looks like:
<body> <form id="form1" runat="server"> <script type="text/javascript"> window.onload = setContent; //window.onload = function() { alert("It's loaded!") }; function updateParentPage() { $find('editor').set_content('sample'); window.returnValue = $find('editor').get_content(); self.close(); } function setContent() { $find('<%= editor.ClientID %>').set_content('Text content'); } </script> ...I am getting Error: 'null' is null or not an object JS exception.
I think this is because of not fully loaded HTML Editor:
How can I avoid this (and get HTMLEditor fully loaded) to set the text in the HTMLEditor via JS?
Thanks.
SGWellens
All-Star
126033 Points
10311 Posts
Moderator
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 02:09 PM|LINK
Is it possible the find function, $find('editor'), is not finding the editor and returning null?
My blog
Heloril
Participant
1470 Points
255 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 02:12 PM|LINK
Hi,
And if you yout try with UniqueID:
<script type="text/javascript"> window.onload = setContent; //window.onload = function() { alert("It's loaded!") }; function updateParentPage() { $find('editor').set_content('sample'); window.returnValue = $find('<%= editor.UniqueID %>').get_content(); self.close(); } function setContent() { $find('<%= editor.UniqueID %>').set_content('Text content'); } </script>Hope it helps,
Helori.
My blog: http://www.notesfor.net/
agentZuluka
Member
1 Points
5 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 02:33 PM|LINK
Unfortunately no, UniqueID does not help.
When I use simple alert:
window.onload = function() { alert("It's loaded!") };
I can see that body of HTMLEditor get's loaded (as on picture), but toolbar only loading after I press OK on alert window.
agentZuluka
Member
1 Points
5 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 02:36 PM|LINK
Maybe the reason is that HTMLEditor report to DOM as loaded when actually it still need to load tollbar?
Heloril
Participant
1470 Points
255 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 02:40 PM|LINK
And what happen if you type:
window.onload = function() { alert($find('<%= editor.UniqueID %>'))};
My blog: http://www.notesfor.net/
agentZuluka
Member
1 Points
5 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 10, 2009 02:50 PM|LINK
I am getting null.
And that's strange, because on window close I am getting correct content:
window.returnValue = $find('editor').get_content();Heloril
Participant
1470 Points
255 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 11, 2009 07:37 AM|LINK
Hi,
Try this:
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <script type="text/javascript"> function pageLoad(sender, args) { $find("<%= Editor1.UniqueID %>").set_content("test"); } </script> <cc1:Editor ID="Editor1" runat="server" />Regards,
Helori.
My blog: http://www.notesfor.net/
agentZuluka
Member
1 Points
5 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 11, 2009 09:06 AM|LINK
Thanks, this is working fine!
But I would like to know why simple window.onload don't work.
ajaxcontrolkit HTMLEditor
Heloril
Participant
1470 Points
255 Posts
Re: Setting text in JavaScript for HTMLEditor after Page was loaded
Aug 11, 2009 09:18 AM|LINK
load Event
Raised after all scripts have been loaded and all objects in the application that are created by using $create are initialized. The load event is raised for all postbacks to the server, which includes asynchronous postbacks.
If you are a page developer, you can create a function that has the name pageLoad, which automatically provides a handler for the load event. The pageLoad handler is called after any handlers that have been added to the load event by the add_load method.
The load event takes an eventargs parameter, which is an Sys.ApplicationLoadEventArgs object. You can use the event arguments to determine whether the page is being refreshed as a result of a partial-page update and what components were created since the previous load event was raised.
More info:
http://www.asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx
My blog: http://www.notesfor.net/