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

Radeditor Attributes.Add KeyUp issue

1 Answer 75 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 26 Oct 2011, 09:40 AM
I have a radeditor control inside an asp.net form view insert item template.

 As the user types text into the radeditor, I want to display the text/html inside a seperate label (within the same insert item template) in real time. (Yes, I know that the radeditor has a preview mode, but the real time preview must be seperate to the radeditor in my scenario). 

This is my server side code:
RadEditor re1 = (RadEditor)FormView_RISummaryDetailsFV.FindControl("RadEditorSummaryDescription_RISummaryDetailsFVEditItemTemplate");
Label lab1 = (Label)FormView_RISummaryDetailsFV.FindControl("LabelResumePreviewHeader_RISummaryDetailsFVEditItemTemplate");
Label lab2 = (Label)FormView_RISummaryDetailsFV.FindControl("LabelResumePreviewContents_RISummaryDetailsFVEditItemTemplate");
 
 
re1.Attributes.Add("onKeyUp", "JavaScript:summaryRealTimePreview('" + re1.ClientID + "', '" + lab1.ClientID + "', '" + lab2.ClientID + "');");

This is my JavaScript code:
<script type="text/javascript" >
    function summaryRealTimePreview(re1_id, lab1_id, lab2_id) {
        var re1 = $find(re1_id);
        var lab1 = document.getElementById(lab1_id);
        var lab2 = document.getElementById(lab2_id);
 
 
        lab1.innerHTML = re1.get_html();
        lab2.innerHTML = re1.get_html();
    }
</script>


Also, I have attempted to implement the onClientLoad="onClientLoad" function of the RadEditor control, but I am unable to find the two required labels which are both inside the insert item template, such as:

<telerik:RadEditor ID="RadEditor1" runat="server" onClientLoad="OnClientLoad" />

<script language="javascript" type="text/javascript">
    function OnClientLoad(editor) {
        var element = document.all ? editor.get_document().body : editor.get_document();
        $telerik.addExternalHandler(element, "keyup", keyUpFunction);
    }
 
 
    function keyUpFunction() {
        alert("key up function tripped");
    }
</script>





Can anyone guide me on the correct syntax or correct coding to achieve this?





.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 27 Oct 2011, 11:40 AM
Hi Matt,

This server code will not work re1.Attributes.Add("onKeyUp" because you can attach to the client events of RadEditor's content area only on the client. You can see how to attach to the keyup event of RadEditor in the following article: attachEventHandler.

For example, you can pass the IDs of the label controls to the client from the server using HiddenFields, but this is a general knowledge question which is out of the scope of Telerik support.

All the best,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Editor
Asked by
Matt
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or