Telerik Extensions for ASP.NET MVC

Version Q1 2012, released 04/19/2012

Client-side API

Editor client API

Generated HTML:


About this example ASPXRazor

This example shows how to use the client-side API of Telerik Editor for ASP.NET MVC.

To use the client-side API you should first retrieve the Editor client-side object. The following code snippet shows how to do this:

<script type="text/javascript">
function getEditor(){
    //"Editor" is the value specified by the Name() method.
    var editor = $("#Editor").data("tEditor");
    return editor;
}
</script>

Available client-side methods:

  • You can create a Range object with createRange() method.
    function selectAll() {
        var editor = getEditor(); // Create Editor object.
    
        range = editor.createRange();
        ...
    }
    
  • You can select a Range object by using selectRange(...) method. This method accepts a Range object.
    function selectAll() {
        var editor = getEditor(); // Create Editor object.
        ...
        editor.selectRange(range);
    }
    
  • You can modify selected area with exec(...) method with exec commands.
    function textBold() {
        var editor = getEditor(); // Create Editor object.
        ...
        editor.exec("bold");
    }
    

Get more than expected!

Take the Telerik Extensions for ASP.NET MVC to your Visual Studio projects to truly experience their power. Download your free copy now and jumpstart your development with the available learning resources.

The Extensions are offered in both open source and commercial versions the differences between which are well explained in the licensing FAQ.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Other Demos: