Link to home
Start Free TrialLog in
Avatar of nauman_ahmed
nauman_ahmedFlag for United States of America

asked on

  problem while saving in the database

Hi,

I am using FreeTextBoxEditor in one of my pages.   The following text:


<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test 20050614-11:45 AM</P>

is being stored as

&lt;p&gt;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
&#160;&#160;Test 20050614-11:15:00 AM&lt;/p&gt;  

after using the Server.HtmlEncode().  I am using Server.HtmlDecode() to convert it back to HTML but the problem is that &#160; is converted into an unknow character for space.  
This text when sent as an HTML in the mail appears as follows:

B B B B B B B B B B B B B B B B B B B B B B B B B B B B B B Test 20050614-11:30 AM

Anyone can suggest me how should I correct it?

Thanks, Nauman.

Avatar of Rejojohny
Rejojohny
Flag of United States of America image

is the mail set to be send in the HTML format?
Avatar of nauman_ahmed

ASKER

Yes. The mail format is HTML and I am using aspNetEMail component.
Why are you storing "HTMLencoded" text (in the DB I assume) The DB doesn't care if it's straight html, only the browser.  Also, why are you HTMLencoding in the first place only to decode it later, do you need to display the literal contents of the HTML to the end user?, not what it would render as?
The problem is that while saving the text in the database earlier, &nbsp; was not being saved.
now that's another problem in itself, can you describe that more?  I don't think you should HTMLencode/decond unnecessarily.  It's not a definite process in that what you encode may not be the same thing decoded.
I thought of using Server.HtmlEncode() thinking it may solve the issue as in one of the www.freetextxbox.com demo, they used the Server.HtmlEncode while retrieving the text.  So the problem remains here:

This is a test.......&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aaaaaaa

and this is stored as

This is a test.......                                                aaaaaaa

I tried this in Access DB this time and the field type is Memo.  I tried retrieving the text using FreeTextBox.Text() method and then displayed in a text-area and it was displaying &nbsp; there.  The text when placed in the database looses the &nbsp;.  
The only reason I used the FreeTextBox control in the form is it has the option to clear the MS Word style and can be accessed in code-behind.  I am into this issue from 2-3 days now.  Any relevant input will be a real help for me.

Thanks, Nauman.
http://www.fckeditor.net/demo/default.html

Try this one. It has MS Word style clearing too.

I've had hard times with FreeTextBox too and finally (thanks to raterus) I stoped with FCKEditor
fyi, here is Ramuncikas original question where Fck is discussed: http:/Q_21417977.html
I tried adding the FCKEditor DLL in VS.NET and dragged it to web form.  It is displaying page not found error.

-Nauman.
Look at the post raterus mentioned above
The confusing thing probably 90% of asp.net developers first experience with this editor is there are TWO things you need to download.  The asp.net control is just a wrapper around the real control itself which has all the javascript/images/html/etc...
in htp://www.fckeditor.net there are two downloads you need. One contains .NET DLL file and the other has all the stuff it needs to run (images, javascripts, stylesheets...supportfolder in other words).
heh heh, I had the problem, Ramuncikas then had it, then (likely) nauman had it.  I think I'm going to email mr. FCK and tell him to notify downloaders of the asp.net control that they do need to get the rest of it as well!
Am I getting old? :)
Raterus,

Are you ready to pay 150 euro for each who doesn't get that treirself? :) Quote:
Donors that make an offer of minimum €150,00 will automatically receive 1 year of e-mail support.

And I think two downloads is the main problem and that's all the support is needed/proposed :)
pay money, bah!
>>>heh heh, I had the problem, Ramuncikas then had it, then (likely) nauman had it.  I think I'm going to email mr. FCK and tell him to notify downloaders of the asp.net control that they do need to get the rest of it as well!

:)

yeah it should be better indicate it in the download section.  I found some relevant material regarding getting the HTML output.  Will post the result tomorrow.

Thanks for the help experts! :)

-Nauman.

Hi experts!

FCKEditor is working really well. However there is one problem regarding the Spell Checker, its client side and I want a server side spell checker.  FreeTextBox uses Netspell but I couldnt find
anything related to implement Netspell in FCK Editor.  Any idea about it?

Thanks, Nauman.
http://fckeditor.wikiwikiweb.de/Developer%27s_Guide/Configuration/Spell_Checker

This should go over everything, there is a server-side speller available, but you will need to install PHP on your webserver, and a few other configuration changes.
I somehow able to solve the issue with FreeTextBox. Here is a work around:  The solution is when the value of FreeTextBox is accessed from JavaScript it shows the pure
HTML code too. So the catch is access the value from JavaScript, set the value of FreeTextBox in a hidden variable and then perform a PostBack from javascript:

Add the following to the ASPX page:

<input type="hidden" id="hdText" name="hdText" runat="server">
<script language="javascript">
                  function getSource()
                  {
                        var str = document.forms[0].FreeTextBox1.value;
                        document.forms[0].hdText.value = str;
                        __doPostBack("","");
                  }
            </script>

in the source code:

this.Button1.Attributes.Add("onClick","javascript:return getSource();");

Now when I access the value of hidden variable hdText inside another multiline text-box, its displaying the value correctly with &nbsp;

this.TextBox1.Text = this.hdText.Value;      

I am testing the solution and will post if it is successfull :)

Thanks for the help.

-Nauman.
ASKER CERTIFIED SOLUTION
Avatar of DarthMod
DarthMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial