Efficient way of adjusting all editors on page

6 posts, 1 answers
  1. Benjamin
    Benjamin avatar
    51 posts
    Member since:
    Jul 2016

    Posted 04 Jul Link to this post

    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

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 04 Jul Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Benjamin
    Benjamin avatar
    51 posts
    Member since:
    Jul 2016

    Posted 04 Jul in reply to Marin Bratanov Link to this post

    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.}

  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 05 Jul Link to this post

    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.
  6. Benjamin
    Benjamin avatar
    51 posts
    Member since:
    Jul 2016

    Posted 05 Jul in reply to Marin Bratanov Link to this post

    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

  7. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 05 Jul Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017