Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Created August 12, 2010 21:08
Show Gist options
  • Select an option

  • Save dieseltravis/521736 to your computer and use it in GitHub Desktop.

Select an option

Save dieseltravis/521736 to your computer and use it in GitHub Desktop.
Find the RadEditor in a control
// There's a RadEditor in there somewhere...
using Telerik.Web.UI;
private RadEditor GetRadEditor(Control c)
{
RadEditor re = null;
try
{
re = (RadEditor)c;
}
catch (InvalidCastException)
{
foreach (Control subc in c.Controls)
{
re = GetRadEditor(subc);
if (re != null) break;
}
}
return re;
}
// example:
protected void Page_Load(object sender, EventArgs e)
{
RadEditor re = GetRadEditor(ControlEditor1);
re.CssFiles.Clear();
re.CssFiles.Add("~/Sitefinity/ControlTemplates/EditorContentArea.css");
}
Private Function GetRadEditor(c As Control) As RadEditor
Dim re As RadEditor = Nothing
Try
re = DirectCast(c, RadEditor)
Catch ex As InvalidCastException
For Each subc As Control In c.Controls
re = GetRadEditor(subc)
If re IsNot Nothing Then
Exit For
End If
Next
End Try
Return re
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment