Attempting to use the Editor as an MVC EditorTemplate

7 posts, 0 answers
  1. Robert
    Robert avatar
    38 posts
    Member since:
    Feb 2012

    Posted 14 Mar 2012 Link to this post

    Hello,



    I am attempting to use the Editor control as an EditorTemplate for HTML fields in my MVC4 application. The editor will display fine, but for some reason the code will never update and the value always comes back up the Model as null. Any ideas what I am doing wrong?



    Here is the code for Html.cshtml:



    @model System.String

    @Html.AntiForgeryToken()

    <textarea id="@Html.DisplayNameFor(c => c)" rows="10" cols="30" style="width:500px;height:250px">@Model</textarea>

    <script>

    $(document).ready(function () {

    $("#@Html.DisplayNameFor(c => c)").kendoEditor();

    });

    </script>



    Thanks!
  2. John
    John avatar
    7 posts
    Member since:
    Jul 2011

    Posted 14 Mar 2012 Link to this post

    Adding a name attribute/value pair to your textarea element should resolve this behaviour.
  3. Kendo UI is VS 2017 Ready
  4. Andrey
    Andrey avatar
    2 posts
    Member since:
    Jan 2012

    Posted 16 Jun 2012 Link to this post

    Hi Robert,

    I use following code for this purpose:
     <div class="editor-field">
             @Html.TextAreaFor(m => m.Description, new {style="width:600px;height:200px"})
     </div>

    <script>
        $(document).ready(function () {
            $("#Description").kendoEditor();
        });
    </script>

    Works fine.
  5. Mikael
    Mikael avatar
    4 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    Hi Andrey, 

    I have tried your code and it works in IE9 but not in Chrome. In Chrome the Text is always null in the Model.

    Any ideas what to change?

    I have now:

    <script type="text/javascript">
        $(document).ready(function () {
            $("#Text").kendoEditor({
                encoded: false
            });
        });
    </script>

    @Html.TextAreaFor(m => m.Text, new {style="width:600px;height:200px"})  
  6. Andrey
    Andrey avatar
    2 posts
    Member since:
    Jan 2012

    Posted 18 Jun 2012 Link to this post

    Hi Mikael,

    Unfortunately I can't reproduce the wrong behavior for Chrome. In my projects it works everywhere.
    What MVC version do you use? 
  7. Mikael
    Mikael avatar
    4 posts
    Member since:
    Jun 2012

    Posted 19 Jun 2012 Link to this post

    Hi, 

    we use MVC4. 
  8. Mikael
    Mikael avatar
    4 posts
    Member since:
    Jun 2012

    Posted 06 Jul 2012 Link to this post

    Hi, 

    issue has been solved, problem was that the form was placed inside a table element. IE fixed this automatically and Chrome did not.

    Now everything works fine with Kendo Editor in both IE and Chrome.
Back to Top
Kendo UI is VS 2017 Ready