1

I'm using AjaxControlToolkit.HTMLEditor, and I want to add a 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?

EDIT This is the 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.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Lucky Luck
  • 99
  • 3
  • 13
  • May I ask how this is related to jQuery? – James Wiseman Oct 11 '10 at 10:00
  • I deleted those tags, it is not related to jQuery, we are talking about methods of the ASP.NET AJAX Control Toolkit. – netadictos Oct 11 '10 at 10:32
  • Out of interest, you didn't accept answers on http://stackoverflow.com/questions/2099370/how-do-i-show-keywords-and-a-search-box-under-my-sites-google-results or http://stackoverflow.com/questions/3003649/website-webservice-to-fetch-data-from-pc or http://stackoverflow.com/questions/3394262/how-to-play-mp4-video-on-window-webserver-in-quick-time-and-flash-playerflv-play. Were they not helpful? You also duplicated this question, incorrectly tagged, and are now including detail in the comments. Suggest you read the FAQ: http://stackoverflow.com/faq section titled: "How do I ask questions here?" – James Wiseman Oct 11 '10 at 14:42
  • yeah James you are right... i read the faqs.. – Lucky Luck Oct 12 '10 at 10:33
  • Did you find the right answer? – netadictos Oct 28 '10 at 06:56

2 Answers2

1

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 $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.

Community
  • 1
  • 1
James Wiseman
  • 29,946
  • 17
  • 95
  • 158
  • 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 Oct 11 '10 at 10:42
  • 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 Oct 11 '10 at 10:43
  • The way to insert text with javascript is the method ("set_content"), as I explain to you in my answer. – netadictos Oct 11 '10 at 10:45
  • 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 Oct 11 '10 at 10:55
  • this is html code for HTMLEditor: i tried to access like this: alert(document.getElementById("<%= eCompose.ClientID %>")); – Lucky Luck Oct 11 '10 at 10:57
  • Before that i was using FreeTextEditor, and it was working fine with-document.getElementById('').value = "asdfasd" – Lucky Luck Oct 11 '10 at 11:00
  • you have to use $find("<%=eCompose.ClientID%>").set_content("whatever"), and alert( $find("<%=eCompose.ClientID%>").get_content()); – netadictos Oct 11 '10 at 11:04
1

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.

Alex
  • 1,457
  • 1
  • 13
  • 26
netadictos
  • 7,602
  • 2
  • 42
  • 69
  • 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 Oct 11 '10 at 10:30
  • you have to use $find("<%=eCompose.ClientID%>").set_content("whatever"), and alert( $find("<%=eCompose.ClientID%>").get_content()); – netadictos Oct 11 '10 at 11:05
  • 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 Oct 11 '10 at 11:17
  • 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 Oct 11 '10 at 11:29