views:

91

answers:

2

I'm using AjaxControlToolkit.HTMLEditor, and I want to add value to it using javascript or jquery like this:

alert( $find("eCompose_ctl02_ctl01")); // if 

$find("eCompose_ctl02_ctl01").attr('value') = "asdfasdfasdf  asdfasd asdf sf";

also tried like this:

 document.getElementById('eCompose_ctl02_ctl01').value += "ababsakas asdasd l";

But the above code does not insert text into HTMLEditor. Can anyone help me? thanks...

EDIT this is html code for HTMLEditor:

<HTMLEditor:Editor ID="eCompose" runat="server" Height="240px" Width="90%" AutoFocus="true" InitialCleanUp="true" /> 

i tried to access like this:

alert(document.getElementById("<%= eCompose.ClientID %>"))

and got null

+1  A: 

It looks like you might be confusing AJAX.NET and jQuery.

attr() is a valid jQuery function, but am not so sure it is AJAX.NET. $find() is AJAX.NET, whereas $() is jQuery.

Does yor item eCompose_ctl02_ctl01 have a ClientID? I.e what does the rendered HTML look like? Check out http://stackoverflow.com/questions/982662/get-and-find-with-ajax-net for this sort of issue.

Also, what does the alert give you?

Give us some more info, e.g. HTML.

James Wiseman
HTMLEditor basically places an iframe, inside that its main TextEditor is loaded. and below the iframe there is a textarea, and i think the textarea is hidden at first time, textarea become visible when HTMLeditor iframe fails to load.And i was using the textarea id (eCompose_ctl02_ctl01) to insert a value... and it was happenning nothing because textarea was hidden due to the successfully loading of main HTMLeditor...
Lucky Luck
But now how to insert text in the HTMLEditor using javascript, I am working on a forum. below the HTMLEditor there are similies(images/icons), if a user clicks on a simily then its id is inserted into the editor where the I beam is...
Lucky Luck
The way to insert text with javascript is the method ("set_content"), as I explain to you in my answer.
netadictos
yes i agree to you: but the prob is how to identify the HTMLEditor, as we do other html element like this: document.getElementId('')
Lucky Luck
this is html code for HTMLEditor: <HTMLEditor:Editor ID="eCompose" runat="server" Height="240px" Width="90%" AutoFocus="true" InitialCleanUp="true" /> i tried to access like this: alert(document.getElementById("<%= eCompose.ClientID %>"));
Lucky Luck
and alert it: null
Lucky Luck
Before that i was using FreeTextEditor, and it was working fine with-document.getElementById('').value = "asdfasd"
Lucky Luck
you have to use $find("<%=eCompose.ClientID%>").set_content("whatever"), and alert( $find("<%=eCompose.ClientID%>").get_content());
netadictos
+1  A: 

The way to do it using the Ajax methods that .NET provides is: $find("NAME_OF_THE_CONTROL").set_content("Hello world");

NAME_OF_THE_CONTROL is the ClientID of your control, I suppose in this case, eCompose_ctl02_ctl01.

netadictos
Yes, I know, but the way to insert text with javascript is the method ("set_content"), I would say it's a copy of Tinymce.
netadictos
you have to use $find("<%=eCompose.ClientID%>").set_content("whatever"), and alert( $find("<%=eCompose.ClientID%>").get_content());
netadictos
thx netadictos, i hv already tried this, but its not working...
Lucky Luck
It's strange. If you go here http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/HTMLEditor/OtherSamples/ClientSide.htm, using the script tab of firebug, and using this method, $find("editor).set_content("whatever"), this works.
netadictos
yes i have checked but my page source is similar to this page: http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/HTMLEditor/OtherSamples/FullScreen.aspx
Lucky Luck
this works: $find("editor").set_content("whatever")
netadictos
Pls tell me if it was the right answer and vote it. Thx.
netadictos