我使用RadEditor和图像管理器创建了一个控件(关注链接:http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity/radeditor-image-manager)。
当用户点击“插入图像”按钮时,它会显示“ImageLibraryDialog”,用户可以选择图像作为图像-1。
http://www.sitefinity.com/clientsfiles/e12f501e-37c1-6deb-a958-ff0000446526_image-1.png?sfvrsn=0
我的问题是:当单击按钮保存在“ImageLibraryDialog”中时,如何将所选图像附加到radEditor控件。
这是我在.ascx设计师中的代码:
<telerik:RadEditor ID="HtmlSocial" runat="server" Width="600px" ClientIDMode="Static" OnClientLoad="OnClientLoad"
ToolsFile="~/Extensions/RadEditor/ToolsFile.xml"
ContentFilters="EncodeScripts,FixUlBoldItalic,FixEnclosingP,IECleanAnchors,MozEmStrong,ConvertFontToSpan,ConvertToXhtml,IndentHTMLContent"
>
<ImageManager ViewPaths="~/Images" UploadPaths="~/Images" DeletePaths="~/Images" />
<MediaManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
<FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
<DocumentManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" />
<Content>
</Content>
</telerik:RadEditor>
这是打开图像库对话框的脚本:
<script type="text/javascript">
Telerik.Web.UI.Editor.CommandList["LibraryImageManager"] = function (commandName, editor, args) {
var editorArgs = editor.getSelectedElement();
//if (!editorArgs || !editorArgs.nodeName || typeof (editorArgs.nodeName) == "undefined" || editorArgs.nodeName != "A")
// editorArgs = editor.getSelection();
var myCallbackFunction = function (sender, args) {
alert(1);
debugger;
if (typeof(editorArgs.nodeName) != "undefined" && editorArgs.nodeName == "IMG")
args.parentNode.replaceChild(editorArgs, args);
else {
// InsertTextArea();
var cloned = args.cloneNode(true);
var div = args.ownerDocument.createElement("DIV");
div.appendChild(cloned);
editorArgs.pasteHtml(div.innerHTML);
}
};
editor.showExternalDialog(
'<%= ResolveUrl("~/Sitefinity/Dialog/MediaContentManagerDialog/?mode=Image")%>',
editorArgs,
750,
600,
myCallbackFunction,
null,
'ImageLibraryDialog',
true,
Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move,
false,
true);
};
function InsertTextArea() {
var editor = $find('<%=HtmlSocial.ClientID%>');
editor.set_html('<textarea id="myTableToFind" style="overflow:hidden; height: 300px; width: 500px;" border="none"></textarea>');
}
</script>
请告诉我如何在“ImageLibraryDialog”中单击按钮保存时如何将所选图像附加到radEditor控件。
非常感谢你。