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
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) {
}
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.
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.
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
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,
IankoTelerik by Progress
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