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

[Solved] Dynamically add snippets to the Editor tools

1 Answer 40 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dhivakar Jaganathan
Top achievements
Rank 1
Dhivakar Jaganathan asked on 17 Sep 2010, 01:12 AM

Hello - Do you have a sample where i can add snippets dynamically to the editor toolbar.

 

  • ASP.NET MVC version  - MVC 2 with Visual studio 2010 (4.0)
  • OS - XP
  • exact browser version - ie 8
  • exact version of the Telerik product - Telerik Extensions for ASP.NET MVC Open Source Version: 2010.2 825
  • preferred programming language (VB.NET or C#) - C#

thanks

1 Answer, 1 is accepted

Sort by
0
Drasko
Top achievements
Rank 1
answered on 05 Dec 2010, 07:16 PM
Hi. Here is how I've done it:

 <%= Html.Telerik().Editor()
                            .Name("Content").Value(Model.Content).Tools(tools => tools

.Snippets(snippets =>
{
    foreach (SelectListItem it in (IEnumerable<SelectListItem>)ViewData["ContImages"])
    {
        if (it.Value != "0") snippets.Add(it.Text, "<img src=\"/Admin/ShowPhoto/" + it.Value + "\" align=\"left\" />");
    }

}
        ))

%>
 <%= Html.Telerik().Editor()
                            .Name("Content").Value(Model.Content).Tools(tools => tools

.Snippets(snippets =>
{
    foreach (SelectListItem it in (IEnumerable<SelectListItem>)ViewData["ContImages"])
    {
        if (it.Value != "0") snippets.Add(it.Text, "<img src=\"/Admin/ShowPhoto/" + it.Value + "\" align=\"left\" />");
    }

}
        ))

%>
<%= Html.Telerik().Editor()
                            .Name("Content").Value(Model.Content).Tools(tools => tools
 
.Snippets(snippets =>
{
    foreach (SelectListItem it in (IEnumerable<SelectListItem>)ViewData["ContImages"])
    {
        if (it.Value != "0") snippets.Add(it.Text, "<img src=\"/Admin/ShowPhoto/" + it.Value + "\" align=\"left\" />");
    }
 
}
        ))
 
%>

I already had a collection of SelectListItem for my dropdown list so I reused it here. but you can do it for any collection you got.
Tags
Editor
Asked by
Dhivakar Jaganathan
Top achievements
Rank 1
Answers by
Drasko
Top achievements
Rank 1
Share this question
or