Created
August 12, 2010 21:08
-
-
Save dieseltravis/521736 to your computer and use it in GitHub Desktop.
Find the RadEditor in a control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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