如何在asp.net中使用FreeTextBox控件
<FTB:FreeTextBoxID="Free1"
ImageGalleryPath="~/Images"
Language="zh-CN"runat="server"
ButtonDownImage="True"
toolbarlayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,
FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,
FontBackColorPicker|Bold,Italic,Underline,Strikethrough,Superscript,
Subscript,RemoveFormat|JustifyLeft,JustifyRight,
JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,
InsertImage|Cut,Copy,Paste,Delete;Undo,Redo,Print,Save|SymbolsMenu,StylesMenu,
InsertHtmlMenu|InsertRule,InsertDate,InsertTime|InsertTable,EditTable;InsertTableRowAfter,
InsertTableRowBefore,DeleteTableRow;InsertTableColumnAfter,InsertTableColumnBefore,
DeleteTableColumn|InsertForm,InsertTextBox,InsertTextArea,InsertRadioButton,
InsertCheckBox,InsertDropDownList,InsertButton|InsertDiv,EditStyle,InsertImageFromGallery,
Preview,SelectAll,WordClean,NetSpell">
</FTB:FreeTextBox>
<FTB:ImageGalleryid="ImageGallery1" SupportFolder="~/aspnet_client/FreeTextBox/"
AllowImageDelete="true"AllowImageUpload="true"
AllowDirectoryCreate="true" AllowDirectoryDelete="true"runat="Server"/>
这些属性表示允许删除图片和上传图片,允许创建文件夹和删除文件夹。
实例
在aspx文件中再添加一个TestBox做文章的“标题”,一个按钮Button“提交”。
test.aspx.cs:
protectedvoidbtnSubmit_Click(objectsender,EventArgse)
{
stringtitle=this.TextBox1.Text;
stringcontent=this.Free1.Text;
NewsBus.AddNews(title,content);
//Response.Redirect("");
content=NewsBus.getLateNews().Tables[0].Rows[0][2].ToString();
Response.Write(content);//输出最新插入的那条新闻的内容
}
appcode中NewsBus.cs:
publicstaticboolAddNews(stringtitle,stringcontent)
{
Stringstrsql="Insertintotest(title,content)Values(@title,@content)";
SqlParameter[]paras=newSqlParameter[2];
paras[0]=newSqlParameter("@title",SqlDbType.VarChar);
paras[0].Value=title;
paras[1]=newSqlParameter("@content",SqlDbType.VarChar);
paras[1].Value=content;
if(NewsDB.Getcmd(strsql,paras))
{
returntrue;
}
returnfalse;
}
publicstaticDataSetgetLateNews()
{
stringstrsql="selecttop1*fromtestorderbyiddesc";
returnNewsDB.Getds(strsql);
}
appcode中NewsDB.cs:
publicstaticSqlConnectionCreatCon()
{
stringstr=ConfigurationManager.AppSettings["conn"];
returnnewSqlConnection(str);
}
publicstaticDataSetGetds(Stringstrsql)
{
SqlConnectioncon=NewsDB.CreatCon();
DataSetds=null;
try
{
SqlDataAdapterda=newSqlDataAdapter(strsql,con);
ds=newDataSet();
da.Fill(ds);
}
catch(Exceptioner)
{
thrower;
}
returnds;
}
web.config
<configuration>
<appSettings>
<addkey="conn"value="DataSource=XUWEI/SQLEXPRESS;InitialCatalog=TestDatabase;UserID=dnndemo;Password=dnndemo"/>
</appSettings>
</configuration>
最后在标题和内容栏中输入文字,并且添加图片,点击“提交”以后会显示刚输入的内容。其中就包括图片。
其实原理很简单,FreeTextBox在我们将内容栏中的文本输入到数据库的指定字段以后,会判断我们有没有插入图片,
如果有图片则将图片的地址也写入“内容”字段中。
比如我们在FreetextBox的文本框中输入文本:“内容栏,插入图片”,然后再插入一个叫做"pic.jpg","提交"完成以后我们去数据库的表test中看字段content的内容如下:
<P>内容栏,插入图片</P>
<P><IMGheight=366alt=未命名.jpgsrc="/testFTB3/Images/pic.jpg"mce_src="testFTB3/Images/pic.jpg"width=950border=0></P>
而在Images目录下我们也能找到刚才插入的图片"pic.jpg"。这个是由
<FTB:FreeTextBoxID="Free1"
ImageGalleryPath="~/Images" ...
</FTB:FreeTextBox>
相关文章
- ASP.NET MVC (五、HttpClient接口解析)
- asp.net web项目 绑定ip地址运行方式
- asp.net gridview_net core mvc 怎么做增删改查
- .net 温故知新:【10】.NET ORM框架EFCore使用入门之CodeFirs、DBFirst
- ASP.NET 使用Ajax详解编程语言
- .net安装 Linux 上的 ASP.NET 环境(linux安装asp)
- 教你如何用ASP连接MySQL(asp连接mysql教程)
- 使用NET来连接MySQL数据库的简单方法(.net怎么连mysql)
- Asp.net中的页面乱码的问题
- asp.net下用url重写URLReWriter实现任意二级域名的方法
- Asp.net时间操作基类(支持短日期,长日期,时间差)
- asp.net获取机器硬件信息(cpu频率、磁盘可用空间、内存容量等)
- ASP.NET页面中动态增加的控件、添加事件
- asp.net使用Silverlight操作ASPNETDB数据库
- asp.net使用Response.Filter过滤非法词汇
- asp.net中资源文件的使用
- asp经典入门教程在ASP中使用SQL语句
- Asp.net在三层架构中事务的使用实例代码
- 基于ASP.NET的lucene.net全文搜索实现步骤
- .Net中导出数据到Excel(asp.net和winform程序中)
- ASP.NET中相对路径的使用总结
- ASP.NET中水晶报表的使用方法详解
- asp.net使用jquery实现搜索框默认提示功能
- ASP.net全局程序文件Global.asax用法分析
- asp.netC#实现解压缩文件的方法
- asp.net修饰符介绍(关于public、private、protected、internal)