Lucky Luck
Lucky Luck

Reputation: 99

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.

Upvotes: 1

Views: 3571

Answers (2)

netadictos
netadictos

Reputation: 7722

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.

Upvotes: 1

Mutation Person
Mutation Person

Reputation: 30520

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.

Upvotes: 1

Related Questions