Thursday, March 06, 2008

FCKeditor ASP html encoding problem solved

I am working on a website project for a client which I need to incorporate 4 FCKeditor instances on the same page all generated html codes post into access database. All just doing well as after a little bit of hacking the html code posted into the database as expected and display on web page just perfect.

But then another problem arisen, the html code that stored in database didn't retrieved back into FCKeditor correctly when client tried to do content update. Consequently, the data posted back into database gets mass up. After did quite a bit of search on the net, I found out a hint from FCKeditor.net forum where a post described the same problem I am having. On that post a person replied that in order for the html code the be translated correctly those html code need to be save as string variable after retrieve from database before post into FCKeditor. So the following is what I did to get the job done.

////////////////////////////////////////////////////////////////////////////////////////////////
Dim sContent '//!!!!!!! VERY IMPORTANT TO DIM THE VAR OTHERWISE FCKEDITOR HTML ENCODE WON'T WORK !!!!!!!//
sContent = rstbl.Fields.Item("overview").Value
'//!!!!!! after var been declared data stored in var will be treated as STRING !!!!//
Dim oFCKeditor
Set oFCKeditor = New FCKeditor
oFCKeditor.BasePath = "/FCKeditor/"
oFCKeditor.Value = sContent
oFCKeditor.Width = 540
oFCKeditor.Height = 300
oFCKeditor.ToolbarSet = "Default"
oFCKeditor.Create "txtprdoverview"
///////////////////////////////////////////////////////////////////////////////////////////////

** I know this post is not Ubuntu Linux related but this is just a place where I keep a record.

No comments: