This is a migrated thread and some comments may be shown as answers.

Using a RadEditor inside a RadWindow as a popup

7 Answers 261 Views
Window
This is a migrated thread and some comments may be shown as answers.
sarika
Top achievements
Rank 1
sarika asked on 25 Feb 2009, 06:16 PM
Hi,
  I am using a RadWindow as a popup as mentioned in the article below.

http://www.telerik.com/help/aspnet-ajax/window_programmingusingradwindowasadialog.html

In this, I wanted to use a RadEditor object on the dialog page.

The onload attribute of the <body> tag reads the argument and uses it to initialize the dialog.
[Javascript] Initializing the dialog
<body onload = "var currentWindow = GetRadWindow();
var Input = document.getElementById('rdUserInput');
Input.value
= currentWindow.argument;">

The rdUserInput is a RadEditor control. So, when the popup is loaded, I do not see the value displayed in the control. However, if i do an alert of Input.Value, I see the value but it is not displayed inside the control. Why is this so? Can you guide on how to get this working?

Thank you.

7 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 27 Feb 2009, 03:31 PM
Hello sarika,

rdUserInput is an object - but it is not  the javascript RadEditor object. In IE only (in FF your code will not enter the if at all), if no javascript object with such an ID exists, the browser tries to match an HTML element having the same ID.
In this case there is such an object - the root html element of RadEditor.
The correct way to get a reference to the editor is to use $find - just like you would do with any MS AJAX control, e.g.

     var editor = $find("<%=RadEditor1.ClientID%>");
Furthermore, there is no .value property to RadEditor - and I am not sure where you read about it having such a property.
In case you wish to set content to the editor you should use editor.set_html("Some content");

Greetings,
Tervel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sarika
Top achievements
Rank 1
answered on 27 Feb 2009, 10:02 PM
Hi Tervel,
   The control that is being used inside a Telerik RadWindow is Telerik RadEditor control.
 I tried to use editor.set_html("content") as below:

<body onload = "var currentWindow = GetRadWindow();var editor = document.getElementById('<%=rdContent.ClientID %>');editor.set_html(currentWindow.argument);">

If I do an alert to see the ClientID I see the correct control.
But I am getting error as the 'object does not support this property or method'.  It breaks at the point where set_html is used. Are you sure that this property exits? Or I am not using it in the right way.

Thanks,
Sarika
0
Georgi Tunev
Telerik team
answered on 02 Mar 2009, 12:27 PM
Hi sarika,

Please use the $get() function like Tervel suggested.
document.getElementById will return the HTML of the wrapping element, not the editor object. Note that since you will be using server-side IDs in the code, you cannot put the code directly in the onload property, but you should use a separate function, wrapped in a RadCodeBlock.




Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
sarika
Top achievements
Rank 1
answered on 10 Mar 2009, 09:23 PM
Hi Georgi,
  I am new to Ajax and telerik as well. Can you please guide me on how I can use the $get() function to get the RadEditor control? Also please guide me with some sample on how to write a 'separate function, wrapped in a RadCodeBlock'.

Thank you.
Sarika
0
Georgi Tunev
Telerik team
answered on 12 Mar 2009, 11:58 AM
Hello Sarika,

I see that Fiko has already answered your support ticket on the same subject.


Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
maggi
Top achievements
Rank 1
answered on 27 May 2009, 06:04 AM
Hello,

   I am also getting the same error can someone help me too. i tried using var editor = $find("<%=RadEditor1.ClientID%>");  but it shows $find is not defined.

Regards
maggi
0
Shinu
Top achievements
Rank 2
answered on 27 May 2009, 11:27 AM
Hi Maggi,

I guess you are trying to get the client side object in onload event of page body. In ASP.NET AJAX environment, the ASP.NET AJAX controls (including RadControls for ASP.NET AJAX) are created after the page has been loaded. So we cannot access the client side object of RadControls using this approach, instead you can attach pageLoad() event in order to get the client side object. Here is the code that I tried.

ASPX:
 
<telerik:radeditor id="RadEditor1" runat="server" > 
    <Content> 
    </Content> 
</telerik:radeditor> 

JavaScript:
 
<script type="text/javascript">    
function pageLoad()  
{  
    var editor = $find("<%=RadEditor1.ClientID%>"); //get a reference to RadEditor client-side object   
}  
</script> 
Please feel free to share the comments.

Thanks,
Shinu.
Tags
Window
Asked by
sarika
Top achievements
Rank 1
Answers by
Tervel
Telerik team
sarika
Top achievements
Rank 1
Georgi Tunev
Telerik team
maggi
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or