Index: /CKEditor.NET/trunk/CHANGES.html
===================================================================
--- /CKEditor.NET/trunk/CHANGES.html	(revision 6669)
+++ /CKEditor.NET/trunk/CHANGES.html	(revision 6670)
@@ -65,4 +65,12 @@
 	</h1>
 	<h2>
+		CKEditor.NET 3.5.3 (SVN)
+	</h2>
+	<p>
+			Fixed issues:</p>
+	<ul>
+		<li><a href="http://dev.ckeditor.com/ticket/7283">#7283</a> : Entered text is not HTML encoded.</li>
+	</ul>
+	<h2>
 		CKEditor.NET 3.5.2
 	</h2>
Index: /CKEditor.NET/trunk/CKEditor.NET/CKEditorControl.cs
===================================================================
--- /CKEditor.NET/trunk/CKEditor.NET/CKEditorControl.cs	(revision 6669)
+++ /CKEditor.NET/trunk/CKEditor.NET/CKEditorControl.cs	(revision 6670)
@@ -22,5 +22,5 @@
 	[ParseChildren(false)]
 	[Designer("CKEditor.NET.CKEditorControlDesigner")]
-	public class CKEditorControl : TextBox
+	public class CKEditorControl : TextBox, IPostBackDataHandler
 	{
 		#region Changed TextBox Property
@@ -33,12 +33,8 @@
 			get
 			{
-				if (!string.IsNullOrEmpty(base.Text))
-					base.Text = base.Text.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
 				return base.Text;
 			}
 			set
 			{
-				if (!string.IsNullOrEmpty(value))
-					value = value.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
 				base.Text = value;
 			}
@@ -1000,44 +996,47 @@
 			this.RegisterStartupScript(this.GetType(), "CKEDITOR_BASEPATH", string.Format("window.CKEDITOR_BASEPATH = '{0}/';\n", (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.BasePath) : this.BasePath)), true);
 			this.RegisterStartupScript(this.GetType(), "ckeditor", "<script src=\"" + (this.CKEditorJSFile.StartsWith("~") ? this.ResolveUrl(this.CKEditorJSFile) : this.CKEditorJSFile) + timestamp + "\" type=\"text/javascript\"></script>", false);
-			if (HasMsAjax)
-			{
-				string scriptInit = string.Empty;
-
-				// Sys.Application.add_load does not work on browsers != IE
-				// http://msdn.microsoft.com/en-us/library/bb386417.aspx
-				// Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN).
-				scriptInit += @"var CKEditor_Controls=[];function CKEditor_TextBoxEncode(c,d){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[c]=='undefined'){var e=document.getElementById(c);e.value=e.value.replace(/</g,'&lt;').replace(/>/g,'&gt;');}else{var f=CKEDITOR.instances[c];if(d)f.destroy();else f.updateElement();}};(function(){var c=function(){var d=CKEditor_Controls,e=window.pageLoad,f=function(){for(i=d.length;i--;){var g=document.getElementById(d[i]);g.value=g.value.replace(/&lt;/g,'<').replace(/&gt;/g,'>');}};window.pageLoad=function(g,h){if(h.get_isPartialLoad())f();if(e&&typeof e=='function')e.call(this,g,h);};f();};if(window.addEventListener)window.addEventListener('load',c,false);else if(window.attachEvent)window.attachEvent('onload',c);})();
+			string scriptInit = string.Empty;
+
+			// Sys.Application.add_load does not work on browsers != IE
+			// http://msdn.microsoft.com/en-us/library/bb386417.aspx
+			// Check _dev/msajax.js for an uncompressed version (available in CKEditor.Net downloaded from SVN).
+			scriptInit += @"var CKEditor_Controls=[],CKEditor_Init=[];function CKEditor_TextBoxEncode(d,e){if(typeof CKEDITOR=='undefined'||typeof CKEDITOR.instances[d]=='undefined'){var f=document.getElementById(d);f.value=f.value.replace(/</g,'&lt;').replace(/>/g,'&gt;');}else{var g=CKEDITOR.instances[d];if(e)g.destroy();else g.updateElement();}};(function(){var d=function(){var e=CKEditor_Controls,f=CKEditor_Init,g=window.pageLoad,h=function(){for(var i=e.length;i--;){var j=document.getElementById(e[i]);if(j&&j.value&&(j.value.indexOf('<')==-1||j.value.indexOf('>')==-1))j.value=j.value.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');}if(typeof CKEDITOR!='undefined')for(var i=0;i<f.length;i++)f[i].call(this);};window.pageLoad=function(i,j){if(j.get_isPartialLoad())setTimeout(h,0);if(g&&typeof g=='function')g.call(this,i,j);};setTimeout(h,0);};if(window.addEventListener)window.addEventListener('load',d,false);else if(window.attachEvent)window.attachEvent('onload',d);})();
 ";
-
-				this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true);
-				this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}');
+			this.RegisterStartupScript(this.GetType(), "CKEditorForNet", scriptInit, true);
+			this.RegisterStartupScript(this.GetType(), this.ClientID + @"_addControl", string.Format(@"CKEditor_Controls.push('{0}');
 ", this.ClientID), true);
-			}
 			string script = string.Empty;
 			if (this.config.CKEditorEventHandler != null)
 				foreach (object[] item in this.config.CKEditorEventHandler)
 				{
-					script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.on('{0}',{1});
+					script += string.Format(@"CKEditor_Init.push(function(){{CKEDITOR.on('{0}',{1});}});
 ", item[0], item[1]);
 				}
-			script += string.Format(@"if(typeof CKEDITOR != 'undefined') CKEDITOR.replace('{0}',{1});
+			if (this.config.protectedSource != null && this.config.protectedSource.Length > 0)
+			{
+				string proSour = string.Empty;
+				foreach (string item in this.config.protectedSource)
+					proSour += @"
+ckeditor.config.protectedSource.push( " + item + " );";
+				script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined') return;var ckeditor = CKEDITOR.replace('{0}',{1}); {2}}});
+", this.ClientID, prepareJSON(), proSour);
+			}
+			else
+				script += string.Format(@"CKEditor_Init.push(function(){{if(typeof CKEDITOR.instances['{0}']!='undefined') return;CKEDITOR.replace('{0}',{1});}});
 ", this.ClientID, prepareJSON());
 
-			if (HasMsAjax)
-			{
-				bool isInUpdatePanel = false;
-				Control con = this.Parent;
-				if (updatePanel != null)
-					while (con != null)
+			bool isInUpdatePanel = false;
+			Control con = this.Parent;
+			if (updatePanel != null)
+				while (con != null)
+				{
+					if (con.GetType() == updatePanel)
 					{
-						if (con.GetType() == updatePanel)
-						{
-							isInUpdatePanel = true;
-							break;
-						}
-						con = con.Parent;
+						isInUpdatePanel = true;
+						break;
 					}
-				this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0));
-			}
+					con = con.Parent;
+				}
+			this.RegisterOnSubmitStatement(this.GetType(), "aspintegrator_Postback" + this.ClientID, string.Format("CKEditor_TextBoxEncode('{0}', {1}); ", this.ClientID, isInUpdatePanel ? 1 : 0));
 			this.RegisterStartupScript(this.GetType(), "aspintegratorInitial_" + this.ClientID, script, true);
 		}
@@ -1051,4 +1050,25 @@
 			return JSONSerializer.ToJavaScriptObjectNotation(this.config);
 		}
+
+		#endregion
+
+		#region IPostBackDataHandler
+
+		bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
+		{
+			if (this.config.htmlEncodeOutput)
+			{
+				string postedValue = postCollection[postDataKey];
+				postedValue = postedValue.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&");
+				if (this.Text != postedValue)
+				{
+					this.Text = postedValue;
+					return true;
+				}
+			}
+			return false;
+		}
+
+		void IPostBackDataHandler.RaisePostDataChangedEvent() { }
 
 		#endregion
Index: /CKEditor.NET/trunk/_dev/msajax.js
===================================================================
--- /CKEditor.NET/trunk/_dev/msajax.js	(revision 6669)
+++ /CKEditor.NET/trunk/_dev/msajax.js	(revision 6670)
@@ -5,5 +5,6 @@
 
 // The following script is used in CKEditorControl:OnPreRender
-var CKEditor_Controls = [];
+var CKEditor_Controls = [],
+	CKEditor_Init = [];
 
 function CKEditor_TextBoxEncode(cID, inUpdatePanel) {
@@ -26,10 +27,18 @@
 	{
 		var ids = CKEditor_Controls,
+			initFunctions = CKEditor_Init,
 			oldPageLoad = window.pageLoad;
 
-		var fixValues = function () {
-			for (i = ids.length; i--;) {
+		var loadEditors = function() {
+			for (var i = ids.length; i--;) {
 				var e = document.getElementById(ids[i]);
-				e.value = e.value.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
+				if (e && e.value && (e.value.indexOf('<') ==-1 || e.value.indexOf('>') ==-1)) {
+					e.value = e.value.replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&amp;/g, '&');
+				}
+			}
+			if (typeof CKEDITOR != 'undefined') {
+				for (var i = 0; i < initFunctions.length; i++) {
+					initFunctions[i].call(this);
+				}
 			}
 		};
@@ -37,11 +46,12 @@
 		window.pageLoad = function(sender, args) {
 			if (args.get_isPartialLoad()) {
-				fixValues();
+				setTimeout(loadEditors, 0);
 			}
-			if (oldPageLoad && typeof oldPageLoad == 'function')
-			oldPageLoad.call(this, sender, args);
+			if (oldPageLoad && typeof oldPageLoad == 'function') {
+				oldPageLoad.call(this, sender, args);
+			}
 		};
 
-		fixValues();
+		setTimeout(loadEditors, 0);
 	};
 
