RadEditor for ASP.NET

Setting Properties Send comments on this topic.

Glossary Item Box

There are several different ways for setting the properties of RadEditor:

  • Inline in the ASPX/ASCX file

This approach is common in the ASP.NET programming. Its advantages are: easy editing, and no need for compilation in order to apply the changes. Its best usage is to set properties which will not be changed in the application logic:

ASPX Copy Code
<rad:radeditor
   
id="RadEditor1"
   
runat="server"
   
imagespaths="~/images"
   
uploadimagespaths="~/images/new"
   
deleteimagespaths="~/images/new/articles,~/images/new/news"
   
allowthumbnailgeneration="true"
   
thumbsuffix="_tmb"
   
imagesfilters="*.jpg,*.gif"
   
maximagesize="100000">
</
rad:radeditor>
 
  • Using code-behind

This is also a common approach for setting control properties. Its advantage is that most of the improper settings are discovered when the application is compiled, for example if you try to set a string value to an integer property. Complex logic which is dependent on many factors can be created for setting the values of the necessary properties. The disadvantage is that the application must be recompiled to apply the changes. Its best usages are to conditionally set properties or to set them in an event handler:

C# Copy Code
private void Page_Load(object sender, System.EventArgs e)
{
 
if (!IsPostBack)
 {
   
//Get the default newsID from the query string
   
int newsID = int.Parse(Request.QueryString["NewsID"]);

   DataTable news = DataHelper.GetNews(newsID);
   
if (news != null)
   {
     RadEditor1.Html = news[
"Text"];
   }
 }
}

or

C# Copy Code
private void Button1_Click(object sender, System.EventArgs e)
{
 
//The user can type newsID in the text box and edit it
 
int newsID = int.Parse(TextBox1.Text);

 DataTable news = DataHelper.GetNews(newsID);
 
if (news != null)
 {
   RadEditor1.Html = news[
"Text"];
 }
}

 

  • In the ConfigFile.xml

This approach is intended to be used when similar settings must be used for several RadEditor controls in an application. This ensures that configuration of all controls is done from a single location. Its advantages and disadvantages are the same as the inline ASPX/ASCX setting. Detailed instructions for the config file settings can be found in the next topic: Using the ConfigFile.xml.