Skip to content

Commit 74c9430

Browse files
committed
Sync with Kendo UI Professional
1 parent bcadc18 commit 74c9430

15 files changed

+880
-216
lines changed

docs-aspnet/_config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,16 @@ html-helpers/editors/autocomplete/how-to/*,
6767
html-helpers/editors/colorpicker/how-to/*,
6868
html-helpers/editors/datepicker/how-to/*,
6969
html-helpers/editors/dropdownlist/how-to/*,
70-
html-helpers/editors/editor/how-to/*,
7170
html-helpers/editors/multiselect/how-to/*,
72-
html-helpers/editors/slider/how-to/*,
73-
html-helpers/editors/upload/how-to/*,
7471
html-helpers/interactivity/progressbar/how-to/*,
7572
html-helpers/layout/window/how-to/*,
7673
html-helpers/navigation/menu/how-to/*,
7774
html-helpers/navigation/panelbar/how-to/*,
7875
html-helpers/navigation/treeview/how-to/*,
7976
html-helpers/scheduling/scheduler/how-to/*,
8077
tag-helpers/*,
81-
knowledge-base/switch-change-messages-inside-grid.md]
78+
knowledge-base/switch-change-messages-inside-grid.md,
79+
knowledge-base/upload-files-to-database.md]
8280

8381
exclude_navigation: ["knowledge-base/*",
8482
api/kendo.mvc/*,

docs-aspnet/html-helpers/editors/editor/how-to/add-max-length-validation.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

docs-aspnet/html-helpers/editors/editor/how-to/add-new-line-on-enter.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs-aspnet/html-helpers/editors/editor/how-to/database-with-imagebrowser.md

Lines changed: 0 additions & 18 deletions
This file was deleted.

docs-aspnet/html-helpers/editors/editor/how-to/inline-editor-in-editor-template.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs-aspnet/html-helpers/editors/slider/how-to/update-dialog-ajax-forms.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

docs-aspnet/html-helpers/editors/upload/how-to/upload-files-to-a-database.md

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
---
2+
title: Store Images in a Database using the ImageBrowser of the Editor
3+
description: Set up the ImageBrowser of the Telerik UI for {{ site.framework }} Editor to store images in an MS SQL database.
4+
type: how-to
5+
page_title: Store Images in a Database using the ImageBrowser of the Editor
6+
slug: editor-imagebrowser-with-database
7+
tags: editor, image, store, database, sql, browser, core, mvc, telerik
8+
previous_url: /helpers/editors/editor/how-to/database-with-imagebrowser, /html-helpers/editors/editor/how-to/database-with-imagebrowser
9+
res_type: kb
10+
component: editor
11+
---
12+
13+
## Environment
14+
15+
<table>
16+
<tr>
17+
<td>Product</td>
18+
<td> {{ site.product }} Editor</td>
19+
</tr>
20+
<tr>
21+
<td>Progress {{ site.product }} version</td>
22+
<td>2024.4.1112</td>
23+
</tr>
24+
</table>
25+
26+
## Description
27+
28+
How can I use the Editor's ImageBrowser with a database?
29+
30+
## Solution
31+
32+
See the full example on how to [set up the Editor `ImageBrowser` to store the images in an MS SQL database](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/EditorDatabaseImageBrowser) in an ASP.NET MVC application.
33+
34+
1. Implement the `Upload` action, to which the ImageBrowser uploads the selected files.
35+
36+
```HomeController
37+
public ActionResult Upload(string path, HttpPostedFileBase file)
38+
{
39+
if (file != null)
40+
{
41+
var files = new FilesRepository();
42+
var parentFolder = files.GetFolderByPath(path);
43+
if (parentFolder != null)
44+
{
45+
files.SaveImage(parentFolder, file);
46+
return Json(
47+
new FileBrowserEntry
48+
{
49+
Name = Path.GetFileName(file.FileName),
50+
Size = file.ContentLength
51+
}
52+
, "text/plain");
53+
}
54+
}
55+
throw new HttpException(404, "File Not Found");
56+
}
57+
```
58+
59+
1. Implement the `FileRepository` class, which performs the data operations with the database.
60+
61+
```FilesRepository.cs
62+
using System;
63+
using System.Collections.Generic;
64+
using System.IO;
65+
using System.Linq;
66+
using System.Web;
67+
using Kendo.Mvc.UI;
68+
69+
public class FilesRepository
70+
{
71+
private ImageBrowserEntities dataContext;
72+
73+
protected ImageBrowserEntities Db
74+
{
75+
get { return dataContext ?? (dataContext = new ImageBrowserEntities()); }
76+
}
77+
78+
public IEnumerable<FileBrowserEntry> Images(string path)
79+
{
80+
return Images(GetFolderByPath(path));
81+
}
82+
83+
public void SaveImage(Folder parent, HttpPostedFileBase file)
84+
{
85+
var buffer = new byte[file.InputStream.Length];
86+
file.InputStream.Read(buffer, 0, (int) file.InputStream.Length);
87+
var image = new Image
88+
{
89+
Name = Path.GetFileName(file.FileName),
90+
Folder = parent,
91+
Image1 = buffer
92+
};
93+
Db.Images.Add(image);
94+
Db.SaveChanges();
95+
}
96+
97+
//... additional methods...
98+
}
99+
```
100+
101+
## More {{ site.framework }} Editor Resources
102+
103+
* [{{ site.framework }} Editor Documentation]({%slug htmlhelpers_editor_aspnetcore%})
104+
105+
* [{{ site.framework }} Editor Demos](https://demos.telerik.com/{{ site.platform }}/editor/index)
106+
107+
{% if site.core %}
108+
* [{{ site.framework }} Editor Product Page](https://www.telerik.com/aspnet-core-ui/editor)
109+
110+
* [Telerik UI for {{ site.framework }} Video Onboarding Course (Free for trial users and license holders)]({%slug virtualclass_uiforcore%})
111+
112+
* [Telerik UI for {{ site.framework }} Forums](https://www.telerik.com/forums/aspnet-core-ui)
113+
114+
{% else %}
115+
* [{{ site.framework }} Editor Product Page](https://www.telerik.com/aspnet-mvc/editor)
116+
117+
* [Telerik UI for {{ site.framework }} Video Onboarding Course (Free for trial users and license holders)]({%slug virtualclass_uiformvc%})
118+
119+
* [Telerik UI for {{ site.framework }} Forums](https://www.telerik.com/forums/aspnet-mvc)
120+
{% endif %}
121+
122+
## See Also
123+
124+
* [Client-Side API Reference of the Editor for {{ site.framework }}](https://docs.telerik.com/kendo-ui/api/javascript/ui/editor)
125+
* [Server-Side API Reference of the Editor for {{ site.framework }}](https://docs.telerik.com/{{ site.platform }}/api/editor)
126+
{% if site.core %}
127+
* [Server-Side TagHelper API Reference of the Editor for {{ site.framework }}](https://docs.telerik.com/aspnet-core/api/taghelpers/editor)
128+
{% endif %}
129+
* [Telerik UI for {{ site.framework }} Breaking Changes]({%slug breakingchanges_2024%})
130+
* [Telerik UI for {{ site.framework }} Knowledge Base](https://docs.telerik.com/{{ site.platform }}/knowledge-base)

0 commit comments

Comments
 (0)