对于FreeTextBox(版本3.1.6)在ASP.Net 2.0中使用,需要2个文件:FreeTextBox.DLL和ftb.imagegallery.aspx
1.下载最新版FreeTextBox(版本3.1.6),解压
FreeTextBox 3.1.6 (2006/07/18)
博客园本地下载: https://files.cnblogs.com/cleo/FTBv3-1-6.zip
作者网站下载地址:http://freetextbox.com/download/
2.打开ASP.Net2.0项目,添加引用。(如果添加过以前版本的FreeTextBox,先删除以前版本的引用)
3.拷贝ftb.imagegallery.aspx到你要使用FreeTextBox的目录(当然可以是其他,但是可能要设置路径)
4.将FreeTextBox添加到工具栏。(工具栏〉常规〉选择项〉浏览到DLL文件,添加)
5.可以将工具栏上的控件拖入到你的页面了
6.注意:
3.1.6的问题就出在ftb.imagegallery.aspx这个文件里
注意到没有:
<form id="Form1" runat="server" enctype="multipart/form-data">
<FTB:ImageGallery id="ImageGallery1"
JavaScriptLocation="ExternalFile"
UtilityImagesLocation="ExternalFile"
SupportFolder="~/aspnet_client/FreeTextBox/"
AllowImageDelete=false AllowImageUpload=true AllowDirectoryCreate=false AllowDirectoryDelete=false runat="Server" />
</form>
这几行(红色三行),有什么用?管他有什么用呢,反正所有的东西都在FreeTextBox.Dll里,嘿嘿,我猜这是为了给1.1用户用的,删除这三行就可以了
1.插入FreeTextBoxInsert.aspx
![]()
Code
1
<FTB:FreeTextBox ID="Free1" ImageGalleryPath="~/ImageAdmin"
2
runat="server" Text='<%# Bind("Contents") %>'
3
ButtonDownImage="True"
4
ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,InsertImage,InsertImageFromGallery,InsertRule|Cut,Copy,Paste;Undo,Redo,Print">
5
</FTB:FreeTextBox>
![]()
Code
// FreeTextBoxInsert.aspx.cs 存入到数据库 str
public partial class FreeTextBoxInsert : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_Click(object sender, EventArgs e)
{
string ConStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection conn =new SqlConnection(ConStr);
string str = Free1.Text;
DateTime time = DateTime.Now;
//插入
//SqlCommand cmd = new SqlCommand(@"INSERT TABLE1(str,date) Values('aaa','bbb')",conn);
SqlCommand cmd = new SqlCommand(@"INSERT TABLE1(str,date) Values(@aaa,@bbb)", conn);
cmd.Parameters.Add(@"aaa", SqlDbType.NVarChar, 4000).Value = str;
cmd.Parameters.Add("bbb", SqlDbType.DateTime,8).Value = time;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
}
2.访问数据库取出 str并显示
![]()
Code
//------------FreeTextBoxShow.aspx.cs 访问数据库取出 str并显示
public partial class FreeTextBowShow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int id = 7;
DataTable dt = GetStr(id);
string str = dt.Rows[0]["str"].ToString();
Label1.Text = str;
}
string str = "";
public DataTable GetStr(int id)
{
string ConStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
SqlConnection conn = new SqlConnection(ConStr);
SqlCommand cmd = new SqlCommand("Select * from TABLE1 where id = @id ",conn);
cmd.Parameters.Add("id", SqlDbType.Int).Value = id;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
return ds.Tables[0];
}
}
//----------------------------FreeTextBoxShow.aspx
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>