Skip to content

Commit f02a0f9

Browse files
committed
chore(demos): add editor viewcomponent razor pages example
1 parent 2ab28ee commit f02a0f9

File tree

6 files changed

+79
-1
lines changed

6 files changed

+79
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Telerik.Examples.RazorPages.Models
2+
{
3+
public class EditorModel
4+
{
5+
public string Value { get; set; }
6+
}
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@page
2+
@model EditorViewComponentModel
3+
4+
@{
5+
ViewData["Title"] = "Editor - ViewComponent";
6+
}
7+
8+
<h3>@ViewData["Title"]</h3>
9+
10+
@await Component.InvokeAsync("Editor", EditorViewComponentModel.EditorModel)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using Telerik.Examples.RazorPages.Models;
4+
5+
namespace Telerik.Examples.RazorPages.Pages.Editor
6+
{
7+
public class EditorViewComponentModel : PageModel
8+
{
9+
[BindProperty]
10+
public static EditorModel EditorModel { get; set; }
11+
12+
public void OnGet()
13+
{
14+
EditorModel = new EditorModel() { Value = "Some Value" };
15+
}
16+
}
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@model EditorModel
2+
3+
@using Telerik.Examples.RazorPages.Models
4+
@using Kendo.Mvc.UI
5+
6+
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf
7+
8+
@(Html.Kendo().EditorFor(m => m.Value)
9+
.HtmlAttributes(new { style = "width: 100%; height:840px" })
10+
.Tools(tools => tools
11+
.Clear()
12+
.Bold().Italic().Underline()
13+
.JustifyLeft().JustifyCenter().JustifyRight()
14+
.InsertUnorderedList().InsertOrderedList()
15+
.Outdent().Indent()
16+
.CreateLink().Unlink()
17+
.InsertImage()
18+
.TableEditing()
19+
.FontName()
20+
.FontSize()
21+
.ForeColor().BackColor()
22+
)
23+
)
24+
25+
<script>
26+
function forgeryToken() {
27+
return kendo.antiForgeryTokens();
28+
}
29+
</script>

Telerik.Examples.RazorPages/Telerik.Examples.RazorPages/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
}
3232
else
3333
{
34-
app.UseExceptionHandler("/Error");
34+
app.UseDeveloperExceptionPage();
3535
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
3636
app.UseHsts();
3737
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System.Threading.Tasks;
4+
using Telerik.Examples.RazorPages.Models;
5+
6+
namespace Telerik.Examples.RazorPages.ViewComponents
7+
{
8+
public class EditorViewComponent : ViewComponent
9+
{
10+
public async Task<IViewComponentResult> InvokeAsync(EditorModel editorModel)
11+
{
12+
return View("default", editorModel);
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)