在ASP.Net中使用FCKeditor
在ASP.Net中使用FCKeditor
翻譯:linqingfeng
日期:2006-5-8
原文地址:http://wiki.fckeditor.net/Developer%27s_Guide/Integration/ASP.Net
?
?
It is very easy to use FCKeditor in your ASP.Net web pages. Just follow these steps.
[按著下面的步驟你將會很容易的把FCKeditor運用到ASP.Net的頁面中。]
<!--[if !vml]--><!--[endif]-->You must have downloaded and installed (copied it in your web site) the last version of FCKeditor editor before proceeding with these steps. The FCKeditor.Net package doesn't include the core of the editor (JavaScript scripts to be placed in the /FCKeditor/ directory of your site). You can download it from the following URL:
[在這之前,你必須下載和安裝(或復制)FCKeditor的最新版本到你的網站中。FCKeditor.Net程序包并不包含編輯器的核心(JavaScript腳本放置在你的站點中的/FCKeditor/文件夾下面)。你可以從以下網址下載到它:]
[[BR]] http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=75845
Step 1
[步驟1]
Suppose that the editor is installed in the /FCKeditor/ path of your web site. Now you need to download the FCKeditor ASP.Net Control DLL to use in your pages. You can find the last version here:
[假如編輯器的安裝路徑是在你站點的/FCKeditor/目錄下。你還需要下載FCKeditor ASP.Net Control DLL以致能運用到你的網頁中去。在這里可以下載到最新的版本:]
http://sourceforge.net/project/showfiles.php?group_id=75348&package_id=137125
Step 2
[步驟2]
The downloaded ZIP file contains the original source code of the control and a compiled version (in the "bin" directory"). So now, just create a reference to the compiled version. You have two options to do that:
[在你下載的ZIP壓縮包里面包含有源代碼和一個編譯過的版本(在“bin”文件夾中)。現在,你就可以用以下兩種方法來創建編譯版本的引用了:]
- Right-clicking in "References" in your Visual Studio.Net project.
[在你的Visual Studio.Net項目中鼠標右擊"References"。] - Manually copying the DLL to the "bin" directory of your web site.
[手動把DLL文件復制到你站點下的“bin”目錄下。]
You can include the control in your Visual Studio.Net controls toolbox. Just right-click on it and select "Add/Remove Items...". Then, just point to the downloaded DLL.
[只要在Visual Studio.Net工具箱中右擊選擇"Add/Remove Items...",選擇剛才下載的DLL文件,就可以把它添加到工具箱中。]
Step 3
[步驟3]
Now the editor is ready to be used in your site, so just create a ASP.Net page and, to create an instance of the editor, you have two options:
[現在就可以把編輯器運用到你的站點中去,你有如下兩種方法創建一個包含有編輯器的實例ASP.Net頁面:]
- Just drag and drop the control in your page from the toolbox (if you have added it to the toolbox as described at "Step 2").
[把它從工具箱中拖拉出來(如果你如“步驟2”所說的那樣把它加到工具箱的話)] - Include the following line in the top of your ASP.Net page source:
[先把下面代碼加到ASP.Net代碼的頂端:]
<%@ Register TagPrefix="FCKeditorV2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %>
And then adding the editor tag inside a <FORM runat="server">:
[然后在添加編輯器時包含標記<FORM runat="server">:]
<FCKeditorV2:FCKeditor id="FCKeditor1" runat="server"></FCKeditorV2:FCKeditor>
The complete sample
[完整的例子]
<%@ Page ValidateRequest="false" Language="C#" AutoEventWireup="false" %>
<%@ Register TagPrefix="FCKeditorV2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %>
<html>
? <head>
??? <title>FCKeditor - Sample</title>
??? <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? </head>
? <body>
??? <form runat="server">
????? <FCKeditorV2:FCKeditor id="FCKeditor1" runat="server"></FCKeditorV2:FCKeditor>
????? <br>
????? <input type="submit" value="Submit" runat="server">
??? </form>
? </body>
</html>
Samples
[示例]
You can find some samples on how to use the editor in the "_samples/aspx" directory of the FCKeditor.Net distribution package. To install the samples, just copy that directory to the _samples directory found in the FCKeditor core package installation.
[在FCKeditor.Net發行包中的“_samples/aspx”目錄下,你能夠找到一些如何使用編輯器的示例。如果要安裝這些示例,只要從FCKeditor安裝包中復制_samples文件夾過來就可以了。]
Properties
[屬性]
The following properties are exposed by the ASP.NET server control.
[以下是可由ASP.NET服務器控制的屬性。]
AutoDetectLanguage
BaseHref
BasePath
ContentLangDirection
CustomConfigurationsPath
Debug
DefaultLanguage
EditorAreaCSS
EnableSourceXHTML
EnableViewState
EnableXHTML
FillEmptyBlocks
FontColors
FontFormats
FontNames
FontSizes
ForcePasteAsPlainText
ForceSimpleAmpersand
FormatIndentator
FormatOutput
FormatSource
FullPage
GeckoUseSPAN
Height
ID
ImageBrowserURL
LinkBrowserURL
PluginsPath
runat
SkinPath
StartupFocus
StylesXMLPath
TabSpaces
ToolbarCanCollapse
ToolbarSet
ToolbarStartExpanded
UseBROnCarriageReturn
Value
Visible
Width
The following events are raised by the ASP.NET server control.
[以下是可由ASP.NET服務器控制的屬性。]
OnDataBinding
OnDisposed
OnInit
OnLoad
OnPreRender
OnUnload
Special note if you are using Asp.net 2.0 and themes: you must open up \editor\filemanager\upload\aspx\upload.aspx and editor\filemanager\browser\default\connectors\aspx\connector.aspx and modify the first line to add Theme="" as follows: <%@ Page language="c#" Inherits="FredCK.FCKeditorV2.FileBrowserConnector" AutoEventWireup="false" Theme="" %>
[如果你使用Asp.net 2.0和主題,要特別注意:你必須展開\editor\filemanager\upload\aspx\upload.aspx和editor\filemanager\browser\default\connectors\aspx\connector.aspx,就像這樣在第一行上加Theme="":<%@ Page language="c#" Inherits="FredCK.FCKeditorV2.FileBrowserConnector" AutoEventWireup="false" Theme="" %>]
You can set the default UserFiles path in your web.config file:
[你能夠在web.config文件中設置默認的UserFiles路徑:]
<appSettings>
?? <add key="FCKeditor:UserFilesPath" value="/Wherever/Files" />
</appSettings>
Changing the UserFilesPath to be dynamic
[動態改變UserFilesPath]
Suppose you would like to modify the location of user uploaded files. You can do so without dynamically adding the control, but you should do so in the page init, not the page load. For example, here is an example which uses files for each team in the same directory:
[假如你想修改用戶上傳文件的位置。那么可以不用動態添加控件,但你要在頁面初始化時修改,而不是在頁面裝載的時候。例如,在下面的例子中,每個組的用戶文件都在一個文件夾中:]
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
?? Session("FCKeditor:UserFilesPath") = "~/App_Images/" & _teamName
End Sub
add an editor Dynamically in your code
[動態添加編輯器到你的代碼中]
if you use an application method (virtual directory), then set the Base path in the web.config file:
[如果你使用應用程序的方法(虛擬目錄),那么要在web.config文件中設置Base路徑:]
For example if this is your FCKeditor path "c:/inetpub/wwwroot/virtualdir/FCKeditor/"
[例如如果這是FCKeditor路徑"c:/inetpub/wwwroot/virtualdir/FCKeditor/"]
add this:
[那么加上:]
<add key="FCKeditor:BasePath" value="~/FCKeditor/"></add>
I use a session to set the filebrowsers path, Add the session variable before you make the control
[如果用事務設置filebrowsers路徑,那么要在使用控件前加上事務的變量]
Session("FCKeditor:UserFilesPath") = "/virtualdir/userfiles/"
Add the control to the page:
[在頁面中添加控件:]
?? ?????????Dim fckeditor As New FredCK.FCKeditorV2.FCKeditor
??????????? fckeditor.ImageBrowserURL = "http://localhost/virtualdir/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connector.aspx"
??????????? fckeditor.ID = "dynamicname"
??????????? fckeditor.Value = "the text you want in the FCK editor"
??????????? fckeditor.SkinPath = "skins/silver/"
??????????? fckeditor.ToolbarSet = "Default"
??????????? myForm.Controls.Add(fckeditor)
?
轉載于:https://www.cnblogs.com/tobin/archive/2007/06/08/776324.html
總結
以上是生活随笔為你收集整理的在ASP.Net中使用FCKeditor的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 面向对象,面向服务(转)
- 下一篇: 保险基础知识:被保险人和投保人