Can someone confirm this problem?
It's driving me nuts..
Been using version 2.0Beta2 of the editor in UserControls in an ASP.NET app and everything works fine.
Upgraded to 2.0RC1 and can't seem to retrieve the Value property of the editor on postbacks? It always defaults to the initial setting.... Works ok in normal webforms (ie .aspx pages) but not in UserControls (ie .ascx)... Could this be something to do with the id of the control when used in UserControls, has something like UcControl1_FCkeditor1 ?
It's driving me nuts..
Been using version 2.0Beta2 of the editor in UserControls in an ASP.NET app and everything works fine.
Upgraded to 2.0RC1 and can't seem to retrieve the Value property of the editor on postbacks? It always defaults to the initial setting.... Works ok in normal webforms (ie .aspx pages) but not in UserControls (ie .ascx)... Could this be something to do with the id of the control when used in UserControls, has something like UcControl1_FCkeditor1 ?
RE: 2.0RC1-Using editor in UserControl in ASP
RE: 2.0RC1-Using editor in UserControl in ASP.NET
I think i figured out what the problem is .. the source code for the FredCK.FCKeditorV2.FCKeditor has changed in RC1!!!!
In FCKeditor.cs file... if u change all references from this.ClientID to this.UniqueID then it works!
Possibly something to do with name & id's of Html elements can't be same..
There's also a minor problem with the BasePath property having a default setting of "/FCkeditor/", however the getter returns "" when the ViewState["Value"] is null thus when u set the base path of the control to the default, the actual BasePath will be an empty string not the default of "/FCKeditor/"!!!..
I've also made a few mods to allow for the use of "~" in the BasePath property.. here's my modified version:
namespace FredCK.FCKeditorV2
{
// [ System.Web.AspNetHostingPermission(SecurityAction.LinkDemand) ]
[ DefaultProperty("Value") ]
[ ValidationProperty("Value") ]
[ ToolboxData("<{0}:FCKeditor runat=server></{0}:FCKeditor>") ]
[ Designer("FredCK.FCKeditorV2.FCKeditorDesigner") ]
[ ParseChildren(false) ]
public class FCKeditor : System.Web.UI.Control, IPostBackDataHandler
{
private FCKeditorConfigurations oConfig ;
public FCKeditor()
{
oConfig = new FCKeditorConfigurations() ;
}
[ Browsable( false ) ]
public FCKeditorConfigurations Config
{
get { return oConfig ; }
}
[ DefaultValue( "" ) ]
public string Value
{
get { return (string)IsNull( ViewState["Value"], "" ) ; }
set { ViewState["Value"] = value ; }
}
[ DefaultValue( "/FCKeditor/" ) ]
[ Description( "BasePath of FCKeditor." ) ]
public string BasePath
{
get { return (string)IsNull( ViewState["BasePath"], "/FCKeditor/" ) ; }
set
{
if (!value.EndsWith("/"))
value += "/";
ViewState["BasePath"] = value ;
}
}
[ DefaultValue( "Default" ) ]
[ Description( "ToolbarSet to use." ) ]
public string ToolbarSet
{
get { return (string)IsNull( ViewState["ToolbarSet"], "Default" ) ; }
set { ViewState["ToolbarSet"] = value ; }
}
[ Category( "Appearance" ) ]
[ DefaultValue( "100%" ) ]
public Unit Width
{
get { return (Unit)IsNull( ViewState["Width"], Unit.Parse("100%", CultureInfo.InvariantCulture) ) ; }
set { ViewState["Width"] = value ; }
}
[ Category("Appearance") ]
[ DefaultValue( "200px" ) ]
public Unit Height
{
get { return (Unit)IsNull( ViewState["Height"], Unit.Parse("200px", CultureInfo.InvariantCulture) ) ; }
set { ViewState["Height"] = value ; }
}
public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
if (postCollection[postDataKey] != Value)
{
Value = postCollection[postDataKey];
return true;
}
return false;
}
public bool CheckBrowserCompatibility()
{
System.Web.HttpBrowserCapabilities oBrowser = Page.Request.Browser ;
// Internet Explorer 5.5+ for Windows
if (oBrowser.Browser == "IE" && ( oBrowser.MajorVersion >= 6 || ( oBrowser.MajorVersion == 5 && oBrowser.MinorVersion >= 5 ) ) && oBrowser.Win32)
return true ;
else
{
Match oMatch = Regex.Match( this.Page.Request.UserAgent, @"(?<=Gecko/)\d{8}" ) ;
return ( oMatch.Success && int.Parse( oMatch.Value, CultureInfo.InvariantCulture ) >= 20030210 ) ;
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write( "<div>" ) ;
if ( this.CheckBrowserCompatibility() )
{
string basePath = this.BasePath.Replace("~", System.Web.HttpContext.Current.Request.ApplicationPath);
string sLink = basePath + "editor/fckeditor.html?InstanceName=" + this.UniqueID ;
if ( this.ToolbarSet.Length > 0 ) sLink += "&Toolbar=" + this.ToolbarSet ;
// Render the linked hidden field.
writer.Write(
"<input type=\"hidden\" id=\"{0}\" name=\"{0}\" value=\"{1}\">",
this.UniqueID,
System.Web.HttpUtility.HtmlEncode( this.Value ) ) ;
// Render the configurations hidden field.
writer.Write(
"<input type=\"hidden\" id=\"{0}___Config\" value=\"{1}\">",
this.UniqueID,
this.Config.GetHiddenFieldString() ) ;
// Render the editor IFRAME.
writer.Write(
"<iframe id=\"{0}___Frame\" src=\"{1}\" width=\"{2}\" height=\"{3}\" frameborder=\"no\" scrolling=\"no\"></iframe>",
this.UniqueID,
sLink,
this.Width,
this.Height ) ;
}
else
{
writer.Write(
"<textarea name=\"{0}\" rows=\"4\" cols=\"40\" style=\"width: {1}; height: {2}\" wrap=\"virtual\">{3}</textarea>",
this.UniqueID,
this.Width,
this.Height,
System.Web.HttpUtility.HtmlEncode( this.Value ) ) ;
}
writer.Write( "</div>" ) ;
}
public void RaisePostDataChangedEvent()
{
// Do nothing
}
private object IsNull( object valueToCheck, object replacementValue )
{
return valueToCheck == null ? replacementValue : valueToCheck ;
}
}
}
RE: 2.0RC1-Using editor in UserControl in ASP.NET
Thanks!
RE: 2.0RC1-Using editor in UserControl in ASP.NET
I love you to
lyphtec is the best