在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.
[按著下面的步驟你將會(huì)很容易的把FCKeditor運(yùn)用到ASP.Net的頁(yè)面中。]
<!--[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:
[在這之前,你必須下載和安裝(或復(fù)制)FCKeditor的最新版本到你的網(wǎng)站中。FCKeditor.Net程序包并不包含編輯器的核心(JavaScript腳本放置在你的站點(diǎn)中的/FCKeditor/文件夾下面)。你可以從以下網(wǎng)址下載到它:]
[[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:
[假如編輯器的安裝路徑是在你站點(diǎn)的/FCKeditor/目錄下。你還需要下載FCKeditor ASP.Net Control DLL以致能運(yùn)用到你的網(wǎng)頁(yè)中去。在這里可以下載到最新的版本:]
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壓縮包里面包含有源代碼和一個(gè)編譯過(guò)的版本(在“bin”文件夾中)。現(xiàn)在,你就可以用以下兩種方法來(lái)創(chuàng)建編譯版本的引用了:]
- Right-clicking in "References" in your Visual Studio.Net project.
[在你的Visual Studio.Net項(xiàng)目中鼠標(biāo)右擊"References"。] - Manually copying the DLL to the "bin" directory of your web site.
[手動(dòng)把DLL文件復(fù)制到你站點(diǎn)下的“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:
[現(xiàn)在就可以把編輯器運(yùn)用到你的站點(diǎn)中去,你有如下兩種方法創(chuàng)建一個(gè)包含有編輯器的實(shí)例ASP.Net頁(yè)面:]
- 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").
[把它從工具箱中拖拉出來(lái)(如果你如“步驟2”所說(shuō)的那樣把它加到工具箱的話)] - 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">:
[然后在添加編輯器時(shí)包含標(biāo)記<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發(fā)行包中的“_samples/aspx”目錄下,你能夠找到一些如何使用編輯器的示例。如果要安裝這些示例,只要從FCKeditor安裝包中復(fù)制_samples文件夾過(guò)來(lái)就可以了。]
Properties
[屬性]
The following properties are exposed by the ASP.NET server control.
[以下是可由ASP.NET服務(wù)器控制的屬性。]
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服務(wù)器控制的屬性。]
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和主題,要特別注意:你必須展開(kāi)\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文件中設(shè)置默認(rèn)的UserFiles路徑:]
<appSettings>
?? <add key="FCKeditor:UserFilesPath" value="/Wherever/Files" />
</appSettings>
Changing the UserFilesPath to be dynamic
[動(dòng)態(tài)改變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:
[假如你想修改用戶上傳文件的位置。那么可以不用動(dòng)態(tài)添加控件,但你要在頁(yè)面初始化時(shí)修改,而不是在頁(yè)面裝載的時(shí)候。例如,在下面的例子中,每個(gè)組的用戶文件都在一個(gè)文件夾中:]
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
[動(dòng)態(tài)添加編輯器到你的代碼中]
if you use an application method (virtual directory), then set the Base path in the web.config file:
[如果你使用應(yīng)用程序的方法(虛擬目錄),那么要在web.config文件中設(shè)置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
[如果用事務(wù)設(shè)置filebrowsers路徑,那么要在使用控件前加上事務(wù)的變量]
Session("FCKeditor:UserFilesPath") = "/virtualdir/userfiles/"
Add the control to the page:
[在頁(yè)面中添加控件:]
?? ?????????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)
?
轉(zhuǎn)載于:https://www.cnblogs.com/tobin/archive/2007/06/08/776324.html
總結(jié)
以上是生活随笔為你收集整理的在ASP.Net中使用FCKeditor的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 面向对象,面向服务(转)
- 下一篇: asp.net 中datagrid It