简体   繁体   中英

Inserting value to AjaxControlToolkit.HTMLEditor using JavaScript

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 .

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? Ie 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, eg HTML.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM