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

if changed then save.... (howto-going crazy)

1 Answer 26 Views
Editor
This is a migrated thread and some comments may be shown as answers.
aykut
Top achievements
Rank 1
aykut asked on 14 Sep 2012, 09:05 PM
dear friends,

I need a working sample that shows me if radeditor changed or not. I cannot simply use "if radeditor1.changed then savecontent" command. there are many possibilities and solutions of the forum. keydown event is first to control, copy paste, menu events etc. there are several solutions but nobody posted a fully functional example. I coluldn't manage combine all of them: can somebody help me please, I'm going crazy for 2 days. isnt there a simple way to learn if user changed the content of radeditor ? it cannot be so hard. I'm ready to accept that I'm an idiot but couldnt make it.

best regards...

(to admins: I posted code library section by mistake, sorry)

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 18 Sep 2012, 02:22 PM
Hi,

You can use the following code:

<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad">
</telerik:RadEditor>
<script type="text/javascript">
var contentChanged = false;
function OnClientLoad(editor) {
editor.attachEventHandler("keydown", function(sender, e) {
contentChanged = true;
});
}
window.onbeforeunload = unloadMessage;
function unloadMessage() {
message = "Content has changed, save before exit?"
if (contentChanged)
return message;
}
</script>
<asp:Button ID="Button1" Text="text" runat="server" />

If the content is updated, the browser will ask the user whether she/he wants to proceed if the user tries to close the window or navigate to another page.

Of course this is a base solution that should be enhanced by the developer working with the control.

Regards,
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
aykut
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or