Dong Lam Trien

Dong Lam Trien

  • 836
  • 986
  • 147.8k

How to use FCKeditorV2 instead of FreeTextBox ?

Jan 15 2020 1:13 PM
I want to use FCKeditorV2 (Figure 2) http://www.mediafire.com/view/oahtm7k3883elow/website2010_10a.jpg/file
instead of FreeTextBox (Figure 1) http://www.mediafire.com/view/pdmvi0aezyqpil5/website2010_10b.jpg/file
 
The code I have edited
[CODE]
In file ArticleAddEdit.aspx 
line 5: 
original
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
 
edit
<%@ Register TagPrefix="FCKeditorV2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %> 
 
 
 line 79:
 original: 
<FTB:FreeTextBox id="txtBody"
TabIndex="3"
toolbarlayout="FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,Strikethrough,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink|InsertTable,EditTable,InsertImageFromGallery"
runat="Server"
Width="585px" Height="200px"
/>
 
edit:
 <FCKeditorV2:FCKeditor id="txtBody" ToolbarSet="MyToolbar" Width="600" Height="300" BasePath="~/FCKeditor/" runat="server" />
 
[/CODE] 
But when I change the code the following error message: http://www.mediafire.com/view/zpze8g7k7o3wm4a/website2010_10c.jpg/file
 
Line 40: txtTitle.Text = obj.Title;
Line 41: txtExcerpt.Text = obj.Excerpt;
Line 42: txtBody.Text = obj.Body;
Line 43: if (obj.Priority == 1)
Line 44: chkPriority.Checked = true;
 
For the original code
[CODE] 
In file In file ArticleAddEdit.aspx
<%@ Page ValidateRequest="false" Language="C#" Theme="WebMaster" MasterPageFile="~/WebMaster/MasterPage.master" AutoEventWireup="true" CodeFile="ArticleAddEdit.aspx.cs" Inherits="webapp4U.UI.ArticleAddEdit" %>
<%@ Register Src="~/WebMaster/Controls/Title.ascx" TagName="Title" TagPrefix="uc" %>
<%@ Import Namespace="webapp4U" %>
<%@ Register TagPrefix="webapp4U" Namespace="webapp4U.UI" %>
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PageContent" Runat="Server">
<uc:Title runat="server" ResourceKey='' Text='c?p nh?t bài vi?t' />
<table width="595" border="0" align="center" cellpadding="0" cellspacing="0">
<tr style="padding-top:5pt;">
<td colspan="2" align="center">
<asp:Label runat="server" ID="lblMsg" Font-Bold="true" ForeColor="blue"></asp:Label>
</td>
</tr>
<tr>
<td width="75%" >
<asp:ValidationSummary runat="server" ID="valChangePasswordSummary" ShowMessageBox="true" ShowSummary="false" />
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><b><%=ResourceManager.GetString("ArticleCategory") %>:</b></td>
</tr>
<tr>
<td style="padding-top:3pt;">
<webapp4U:ddlArticleCategory ID="dlArticleCategory" runat="server" CssClass="Textbox" />
<asp:RangeValidator runat="server" ControlToValidate="dlArticleCategory" ID="rvl1"
Type="Integer" MinimumValue="2" MaximumValue="1000" Display="dynamic"
ErrorMessage="Category not null" />
</td>
</tr>
<tr>
<td style="padding-top:10pt;"><b><%=ResourceManager.GetString("Title") %>:</b></td>
</tr>
<tr>
<td style="padding-top:3pt;">
<asp:TextBox ID="txtTitle" TabIndex="1" Font-Bold="true" runat="server" Width="380" MaxLength="500"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtTitle" runat="server" ErrorMessage="Title not null" Display="None" />
</td>
</tr>
<tr>
<td style="padding-top:10pt;"><b><%=ResourceManager.GetString("Article_Trichdan") %>:</b></td>
</tr>
<tr style="padding-top:3pt;">
<td>
<asp:TextBox ID="txtExcerpt" TabIndex="2" TextMode="MultiLine" Rows="5" runat="server" Width="380" MaxLength="3000"></asp:TextBox>
</td>
</tr>
</table>
</td>
<td valign="top" width="90" style="padding-top:20pt;">
<table border="0" cellpadding="0" width="90" >
<tr>
<td style="padding-top:5pt;" height="90" width="100%" valign="top" align="center">
<img name="ImageItem" id="ImageItem" runat="server" border="1" src="~/WebMaster/Images/Picture.jpg" width="80"/>
<input type="hidden" runat="server" id="HiddenImageName" name="HiddenImageName" value="" />
<input type="hidden" runat="server" id="HiddenImageWidth" name="HiddenImageWidth" value="-1" />
<input type="hidden" runat="server" id="HiddenImageHeight" name="HiddenImageHeight" value="-1" />
</td>
</tr>
<tr>
<td>
<input type="button" class="btupload" value=" Upload Picture" onclick='window.open("UploadFile.aspx?ActUpload=article","khunghinh","width=420,height=200,menubar=no,scrollbars=yes")' />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><br /></td>
</tr>
<tr style="padding-top:8pt; padding-bottom:3pt;">
<td colspan="2" ><b><%=ResourceManager.GetString("Article_Body") %> :</b></td>
</tr>
<tr>
<td colspan="2" style="font-size:0.7em">
<FTB:FreeTextBox id="txtBody"
TabIndex="3"
toolbarlayout="FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,FontBackColorPicker|Bold,Italic,Underline,Strikethrough,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink|InsertTable,EditTable,InsertImageFromGallery"
runat="Server"
Width="585px" Height="200px"
/>
</td>
</tr>
<tr>
<td colspan="2" align="right" style="padding-top:7pt; padding-right:3pt; padding-bottom:20pt;">
<asp:CheckBox runat="server" ID="chkPriority" Text="" TextAlign=Left />
Tin n?i b?t(Hi?n th? trên cùng)
<asp:Button runat="server" TabIndex="4" ID="btSave" OnClick="btSave_Click" Text=" Save " CssClass="textbox" />
</td>
</tr>
</table>
<br /><br /><br /><br />
</asp:Content>
 
 
 
In file In file ArticleAddEdit.aspx.cs
 
namespace webapp4U.UI
{
public partial class ArticleAddEdit : System.Web.UI.Page
{
private int ArticleID = -1;
private int CateID = -1;
protected void Page_Load(object sender, EventArgs e)
{
// lay ArticleID khi chinh sua
ArticleID = Globals.GetIntFromQueryString("ArticleID");
CateID = Globals.GetIntFromQueryString("CateID");
if (Request.QueryString["Action"] == "Edit")
{
btSave.CommandArgument = "Edit";
btSave.Text = " Update ";
if (!IsPostBack)
{
Load_GetItemByArticleID(ArticleID);
}
}
}
protected void Load_GetItemByArticleID(int ArticleID)
{
webapp4U.BOL.Article obj = webapp4U.BOL.Article.GetArticleByArticleID(ArticleID);
txtTitle.Text = obj.Title;
txtExcerpt.Text = obj.Excerpt;
txtBody.Text = obj.Body;
if (obj.Priority == 1)
chkPriority.Checked = true;
if(obj.ImageURL.Length>3)
ImageItem.Src = Globals.ApplicationPath + "/UserUpload/Articles/" + obj.ImageURL;
if (obj.ImageWidth > obj.ImageHeight)
ImageItem.Width = 80;
else
ImageItem.Height = 80;
dlArticleCategory.SelectedValue = obj.ArticleCateID.ToString();
HiddenImageName.Value = obj.ImageURL;
HiddenImageWidth.Value = obj.ImageWidth.ToString();
HiddenImageHeight.Value = obj.ImageHeight.ToString();
}
protected void btSave_Click(object sender, EventArgs e)
{
webapp4U.BOL.Article obj = new webapp4U.BOL.Article();
obj.ArticleID = ArticleID;
obj.Title = txtTitle.Text.Trim();
obj.Excerpt = txtExcerpt.Text.Trim().Replace(Environment.NewLine, "<br>");
obj.Body = txtBody.Text;
obj.PostDate = DateTime.Now;
obj.Priority = 0;
if (chkPriority.Checked)
obj.Priority = 1;
obj.ImageURL = HiddenImageName.Value.Trim();
obj.ImageWidth = Convert.ToInt32(HiddenImageWidth.Value.Trim());
obj.ImageHeight = Convert.ToInt32(HiddenImageHeight.Value.Trim());
obj.Authors = " ";
obj.ArticleCateID = Globals.ConvertToInt32(dlArticleCategory.SelectedItem.Value);
if (btSave.CommandArgument == "Edit")
{
obj.TotalViews = 0;
webapp4U.BOL.Article.Update(obj);
//Response.Redirect("ArticleDetail.aspx?ArticleID=" + ArticleID);
}
else
{
webapp4U.BOL.Article.Insert(obj);
//txtBody.Text = "";
//txtTitle.Text = "";
//txtExcerpt.Text = "";
}
Response.Redirect("Default.aspx?CateID=" + CateID);
lblMsg.Text = "C?p nh?t thông tin thành công!";
}
}
}
[/CODE]  
or see the attached file: http://www.mediafire.com/file/pzydjnj8zp7jd41/website2010_10.rar/file
Reference links
https://expressmagazine.net/development/1558/huong-dan-dua-fck-editor-vao-web-aspnet
https://docs-old.ckeditor.com/FCKeditor_2.x/Developers_Guide/Integration/ASP.NET