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

Save changes to and print content of Editor in MVC

8 Answers 577 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Goran
Top achievements
Rank 1
Goran asked on 19 Jan 2015, 07:53 AM
Hello,

I'm planning to use Editor in my ASP.NET MVC application to edit and print some HTML content that I store in database. But, as I could see in THIS demo Editor does not contain tools (buttons) such as Save and Print. I've used your ASP.NET Ajax editor in my previous ASP.NET Web Forms applications to achieve same functionality and that editor had this buttons.

My question is, how can I save changes and print ONLY the content of Editor in ASP.NET MVC? Any example?

8 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 20 Jan 2015, 01:55 PM

Hello Goran,

At this time, the editor does not provide a print action. See this Dojo sample for a way to print via a custom tool.

As for saving the editor content, the editor posts the textarea to the controller action when submitting the enclosing form. If you have a string argument of the action method that has the same name as the editor, you get the editor value in it:

@Html.Kendo().Editor().Name("foo")

public ActionResult Save(string foo) {
}

Regards,
Alex Gyoshev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Goran
Top achievements
Rank 1
answered on 20 Jan 2015, 09:15 PM
Thank you for your answer. Unfortunatelly, this printing works only with chrome and firefox but not IE. It prints the whole page, not just the editor content. Even if I put it in compatibility mode it still prints the whole page. Please refer to the attachment.
0
Goran
Top achievements
Rank 1
answered on 20 Jan 2015, 09:52 PM
I must add that even if it works it is fairly hard to implement. Telerik controls were supposed to the ease the development. This is very complex workaround (not a solution) for a very simple task. It's very disapointing to find out that such a simple task is not already implemented in MVC wrappers.
0
Accepted
Alex Gyoshev
Telerik team
answered on 21 Jan 2015, 11:55 AM

Hello Goran,

I have adjusted the approach to work in IE.

The features that you mention are not implemented, nor advertised anywhere on the site. If you need features that are not available, you either need to wait for them to be implemented, or implement them yourself -- the suggested code is meant to help you with that.

Saving data to the database is not a task of the UI framework, but if you need help with this in your application, feel free to open a support ticket that explains the problem.

Regards,
Alex Gyoshev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Goran
Top achievements
Rank 1
answered on 21 Jan 2015, 07:46 PM
Ok, I totally agree :) Fair enoough.
0
Romik
Top achievements
Rank 1
answered on 04 May 2017, 08:31 PM

Hello Alex,

Can you please explain in detail about saving the text in the editor to database?
When you said that Action method should have a string parameter name similar to Editor name, how are we going to direct the button submit to that Action method? 
What are the requirements for the button? How is the button defined?

Thanks

0
Ianko
Telerik team
answered on 09 May 2017, 08:02 AM

Hello Romik,

Uisng Kendo Editor for MVC is the same as if you are going to use a plain  form element and save its content to the database.

Particularly, saving to is not a topic covered by any UI component, but server-side code implementation. Thus, this will not be explained in details as this is a plain technique of saving a string to a database field. 

Kendo Editor utilizes a hidden that has the name and id field set to the value passed in the Name method of the Kendo().Editor() helper. That said, in order to submit the text to a controller you will need a form and a submit button, where the form will navigate to the controller action and the submit button will just trigger the submit action. This is plain HTML form handling and there is nothing more complex when it comes to Kendo Editor. 

As with any form submitting to MVC action, the form fields are captured in the method overload (the parameters). Thus, the Name method (id and name of the ) will be available in the controller action by a parameter with the same name. http://docs.telerik.com/aspnet-mvc/helpers/editor/overview#server-value-processing

All that is utilizing native HTML and MVC techniques and all those are considered as general knowledge for ASP.NET MVC development. You can also check out this resource: https://blog.michaelckennedy.net/2012/01/20/building-asp-net-mvc-forms-with-razor/

Regards,

Ianko
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paul
Top achievements
Rank 1
answered on 30 Mar 2018, 05:28 PM

Thanks, wish you would put this information in the actual documentation somewhere. The existence of a 'change' event client side led me down the wrong path. We generally serialize objects instead of passing individual values in the FormCollection these days. Populating the incoming object (ViewModel) with the value of the Content property would be much more developer friendly.

Thanks, Paul

Tags
Editor
Asked by
Goran
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Goran
Top achievements
Rank 1
Romik
Top achievements
Rank 1
Ianko
Telerik team
Paul
Top achievements
Rank 1
Share this question
or