I'm looking for example code.
I've seen various links to
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Editor/Examples/DBFileBrowserContentProvider/DefaultCS.aspx
but when I go there I can find no example code.
7 Answers, 1 is accepted
I believe that this Code library will be of help.
Regards,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
If you have insrted an image and then you click on that image to select it and then click on the image manager button - is there any way to open the file folders to the slected image folder and, even better, have the image selected and show the image in the preview pane.
I have been through the code and i can't see any way to do this
The following exaple code of yours (DBContentProvider class) picks up the selected image url but does not seem to do anything with it..
If SelectedItemTag <> Nothing AndAlso SelectedItemTag <> String.Empty Then
SelectedItemTag = ExtractPath(RemoveProtocolNameAndServerName(SelectedItemTag))
End If
contained in
Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, _
ByVal selectedItemTag As String)
MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, _
selectedItemTag)
_itemHandlerPath = ConfigurationManager.AppSettings(
"Telerik.WebControls.EditorExamples.ItemHandler")
If _itemHandlerPath.StartsWith("~/") Then
_itemHandlerPath = HttpContext.Current.Request.ApplicationPath + _itemHandlerPath.Substring(1)
End If
If SelectedItemTag <> Nothing AndAlso SelectedItemTag <> String.Empty Then
SelectedItemTag = ExtractPath(RemoveProtocolNameAndServerName(SelectedItemTag))
End If
End Sub
thanks for your help
I am not quite sure that I understand what exactly do you need to achieve. Could you please provide me with little bit more information about your requirements?
Kind regards,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I am having an issue with the Image Manager in the RadEditor.
I insert an image into the editor area using the Image Manager.
I then select the image in the editor area and click the Image Manager button again. When the image dialog window opens it shows the root folder and its sub folders. However the images I am interested in for this particlar page (and the selected image) are in a sub sub folder.
I was hoping that there was some way to get the image manager to open the relevant sub sub folder to reveal the image that is selected. i.e. that it would be able to use the path of the selected image to open folders such that the folder the selected image is in is opened.
If I open the folder that the image is in then the image is shown as selected and is displayed in the preview pane. However I have to open the folder myself.
I would expect that the folder path to the selected image would be opened automatically. However none of you demos seem to show this. In fact - unlike my implementation - none of them seem to even show the selected image as selected in the image dialog window
The demo at
http://demos.telerik.com/aspnet-ajax/editor/examples/filemanagers/defaultcs.aspx
has the same problem.
I have a custom FileBrowserContentProvider for my Image Manager and I can see that when my provider is constructed the first time that the selectedUrl and selectedItemTag parameters are set with the selected image src value but I cannot see what to do with these values. I do pass them to the base constructor in FileBrowserContentProvider.
If you need to highlight the selected image in the file browser when you click on the Image Manager tool then try the code below:
<script type="text/javascript"> /*The code below will allow you to set the PreselectedItemUrl value in the OnClientCommandExecuting event of RadEditor and load the desired location in the Image manager. After that in the OnClientCommandExecuted event you should set the value of oldAdditionalQueryString to null to not apply everytime additional querystring to the dialog when it is being opened:*/ var oldAdditionalQueryString = null; function OnClientCommandExecuting(editor, args) { var selectedElement = editor.getSelectedElement(); if (!selectedElement || selectedElement.tagName != "IMG") { oldAdditionalQueryString = editor.get_dialogOpener().get_additionalQueryString() //random number is added to make the url unique and force the reload of the dialog. //this way we can ensure that the file will be selected when the dialog loads. editor.get_dialogOpener().set_additionalQueryString(oldAdditionalQueryString + "&rndnum="+ (new Date()-100) + "&PreselectedItemUrl=" + encodeURIComponent("/editorQ1SP12009/Images/test/")); //in the encodeURIComponent put the desired image folder location parameter } } function OnClientCommandExecuted(editor, args) { if (oldAdditionalQueryString) { editor.get_dialogOpener().set_additionalQueryString(oldAdditionalQueryString); oldAdditionalQueryString=null; } } </script> <telerik:RadEditor id="RadEditor1" runat="server" OnClientCommandExecuting="OnClientCommandExecuting" OnClientCommandExecuted="OnClientCommandExecuted"> <ImageManager ViewPaths="~/Images" UploadPaths="~/Images" /> </telerik:RadEditor>
Regards,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
But that seems to have no effect
<%
@ Control Language="vb" AutoEventWireup="false" CodeBehind="Editor.ascx.vb" Inherits=".SKEditor" %>
<
div id="<%=Me.ID %>">
<sitekit:ClientScriptBlock ID="ClientScriptBlock1" runat="server">
<script language="javascript" type="text/javascript">
Telerik.Web.UI.Editor.CommandList[
"InsertSpecialLink"] = function(commandName, editor, args) {
var selectedElement = editor.getSelectedElement();
var popUpUrl = "/AdminV9/Link/InsertLink.aspx?sks=" + "<%=SKS%>";
var argument = null;
if (selectedElement.tagName == "A") {
editor.selectElement(selectedElement);
// Set argument as link this will be passed into popup
argument = selectedElement;
}
else {
var content = editor.getSelectionHtml();
if (content.indexOf('<A') > -1 || content.indexOf('</A>') > -1) {
alert(
'Some of the text you have selected already contains a hyperlink. Click inside that hyperlink first to remove it or to edit it. ')
return false;
}
// Create a new link element
var link = editor.get_document().createElement("A");
link.innerHTML = content;
// Set argument as link this will be passed into popup
argument = link;
}
// Modify argument so picker can call web services
argument.SKS =
"<%=SKS%>";
argument.SiteID =
"<%=SiteID%>";
argument.PeopleID =
"<%=PeopleID%>";
var InsertInternalLinkOK = function(sender, args) {
// Google makes the url absolute so use "newHref" property rather that "href"
editor.pasteHtml(String.format(
"<a href={0} target='{1}' class='{2}'>{3}</a>", args.newHref, args.target, args.className, args.innerHTML))
}
editor.showExternalDialog(
popUpUrl,
argument,
600,
500,
InsertInternalLinkOK,
null,
'Insert Link',
true,
Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
false,
true);
};
function OnRadEditorLoad(editor, args) {
// Ensure editors are transparent
var editorframe = editor.get_contentAreaElement();
editorframe.allowTransparency =
true;
editorframe.contentWindow.document.body.style.background =
"transparent";
}
/*The code below will allow you to set the PreselectedItemUrl value in the OnClientCommandExecuting event of RadEditor and load the desired location in the Image manager. After that in the OnClientCommandExecuted event you should set the value of oldAdditionalQueryString to null to not apply everytime additional querystring to the dialog when it is being opened:*/
var oldAdditionalQueryString = null;
function OnClientCommandExecuting(editor, args)
{
var selectedElement = editor.getSelectedElement();
if (!selectedElement || selectedElement.tagName != "IMG")
{
oldAdditionalQueryString = editor.get_dialogOpener().get_additionalQueryString()
//random number is added to make the url unique and force the reload of the dialog.
//this way we can ensure that the file will be selected when the dialog loads.
editor.get_dialogOpener().set_additionalQueryString(oldAdditionalQueryString +
"&rndnum="+ (new Date()-100) + "&PreselectedItemUrl=" + encodeURIComponent("/editorQ1SP12009/Images/test/")); //in the encodeURIComponent put the desired image folder location parameter
}
}
function OnClientCommandExecuted(editor, args)
{
if (oldAdditionalQueryString)
{
editor.get_dialogOpener().set_additionalQueryString(oldAdditionalQueryString);
oldAdditionalQueryString=
null;
}
}
</script>
</sitekit:ClientScriptBlock>
<telerik:RadEditor ID="RadEditor1" runat="server"
OnClientCommandExecuting
="OnClientCommandExecuting" OnClientCommandExecuted="OnClientCommandExecuted"
>
<
ImageManager />
</telerik:RadEditor>
</
div>
'set root for viewing
RadEditor1.ImageManager.ViewPaths = Split(
"/")
Dim objType As Type = GetType(ContentProviders.RadEditor.DBContentProvider)
RadEditor1.ImageManager.ContentProviderTypeName = objType.AssemblyQualifiedName
Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, _
ByVal selectedItemTag As String)
MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, _
selectedItemTag)
_itemHandlerPath = ConfigurationManager.AppSettings("Telerik.WebControls.Editor.ItemHandler")
If _itemHandlerPath.StartsWith("~/") Then
_itemHandlerPath = HttpContext.Current.Request.ApplicationPath + _itemHandlerPath.Substring(1)
End If
End Sub
Public Overloads Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As DirectoryItem
Dim returnValue As New DirectoryItem(GetName(path), GetDirectoryPath(path), path, String.Empty, GetPermissions(path), Nothing, _
GetChildDirectories(path))
Return returnValue
End Function
I have already answered your question in this forum thread.
Regards,
Fiko
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

