This is a migrated thread and some comments may be shown as answers.

Efficient way of adjusting all editors on page

5 Answers 51 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Benjamin
Top achievements
Rank 1
Benjamin asked on 04 Jul 2016, 10:17 AM

Hi,

i managed to set the width of 1 html editor using this way in the C# code

txtDescription.Width = Unit.Pixel(480);
txtDescription.Height = Unit.Pixel(350);

but my page has about 20 editors and some editor are created dynamically via the asp:Repeater.

is there any way to set the height and width of all the editor like for example in ToolsFile.xml or config file?

i would prefer not to touch the editor ascx file as my web application just reference the dll and i do not have the ascx file

5 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 04 Jul 2016, 11:09 AM

Hi Benjamin,

You have several options:

  • use ASP Themes
  • access the control in the ItemDataBound event of the repeater
  • traverse all controls recursively, check their type and set values
  • do that on the client via the setSize method


Regards,

Marin Bratanov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Benjamin
Top achievements
Rank 1
answered on 05 Jul 2016, 01:55 AM

Hi Marin thanks for the reply. 

i would like to check how do i resize those editor not in repeater?

i tried this but it is not entering the if(ctrl is RadEditor)

01.foreach(Control ctrl in Page.Controls)
02.{
03.    if (ctrl is RadEditor)
04.    {
05.       RadEditor control = ctrl as RadEditor;
06.       ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Now setting "+ control.ClientID +" width')", true);
07.                     
08.       if (control != null)
09.       {
10.             control.Width = Unit.Pixel(width);
11.             control.Height = Unit.Pixel(height);
12.       }
13.       else
14.       {
15.          ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Control " + ctrl.ClientID +" not found')", true);
16.                        return;                       
17.       }
18.   }
19.}

0
Marin Bratanov
Telerik team
answered on 05 Jul 2016, 06:48 AM

Hi Benjamin,

Try looping through the form's collection, because the Page contains just the Form object.

foreach (Control ctrl in form1.Controls)

I also advise that you look into recursive traversal in case the editor is in a Panel or other control.

Regards,

Marin Bratanov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Benjamin
Top achievements
Rank 1
answered on 05 Jul 2016, 07:09 AM

his Marin,

sorry for asking this as this is the first time i traverse asp control. 

how do i do recursive traverse as the editor is inside RadMultiPage, RadPageView control

0
Accepted
Marin Bratanov
Telerik team
answered on 05 Jul 2016, 07:25 AM

Hello,

There are numerous examples of recursive traversals in the net, for example:


Regards,

Marin Bratanov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Editor
Asked by
Benjamin
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Benjamin
Top achievements
Rank 1
Share this question
or