Dynamically set editor background colour VB Re Post 8845

Last post 08-06-2009, 6:15 AM by Kenneth. 9 replies.
Sort Posts: Previous Next
  •  08-01-2009, 6:26 AM 54437

    Dynamically set editor background colour VB Re Post 8845

    Using EditorBodyStyle I can progmatically set the editor background colour.
    Can I dynamically set the background colour by passing a variable to the aspx file?
  •  08-02-2009, 7:35 PM 54440 in reply to 54437

    Re: Dynamically set editor background colour VB Re Post 8845

    Hi stevef,
     
    Try this way:
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>   
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    5. <html xmlns="http://www.w3.org/1999/xhtml">   
    6. <head runat="server">   
    7.     <title>Untitled Page</title>   
    8.   
    9.     <script runat="server">   
    10.         string DynamicStyle = "background-color:blue";   
    11.         protected void ChangeColor_Click(object sender, EventArgs e)   
    12.         {   
    13.             Editor1.EditorBodyStyle = DynamicStyle;   
    14.   
    15.         }   
    16.     </script>   
    17.   
    18. </head>   
    19. <body>   
    20.     <form id="form1" runat="server">   
    21.         <CE:Editor ID="Editor1" runat="server" EditorBodyStyle="background-color:red">   
    22.         </CE:Editor>   
    23.         <asp:Button ID="ChangeColor" runat="server" Text="Change editor background color"  
    24.             OnClick="ChangeColor_Click" />   
    25.     </form>   
    26. </body>   
    27. </html>  
    Regards,
     
    Ken
  •  08-03-2009, 3:21 AM 54452 in reply to 54440

    Re: Dynamically set editor background colour VB Re Post 8845

    Thanks Ken,

    I am passing a variable "bgcol" to the editor aspx.

    Public ReadOnly Property bgcol() As String
    Get
    Return Request.QueryString("bgcol").ToString()
    End Get
    End Property

    I was wanting to set the background-color to the variable but ignorant of the coding required.

    EditorBodyStyle="background-color: bgcol ;"

  •  08-03-2009, 5:54 AM 54453 in reply to 54452

    Re: Dynamically set editor background colour VB Re Post 8845

     vb

     

    1. Public ReadOnly Property bgcol() As String  
    2.     Get  
    3.         If Request.QueryString("bgcol"Is Nothing Then  
    4.             Return Nothing  
    5.         Else  
    6.             Return Request.QueryString("bgcol").ToString()   
    7.            
    8.         End If  
    9.     End Get  
    10. End Property  
    11. Protected Overloads Overrides Sub OnLoad(ByVal e As EventArgs)   
    12.     If bgcol IsNot Nothing Then  
    13.         Editor1.EditorBodyStyle = "background-color:" & bgcol   
    14.     End If  
    15. End Sub  
    c#
    1. public string bgcol   
    2.      {   
    3.          get  
    4.          {   
    5.              return (Request.QueryString["bgcol"] == null) ? null : Request.QueryString["bgcol"].ToString();   
    6.          }   
    7.      }   
    8.      protected override void OnLoad(EventArgs e)   
    9.      {   
    10.          Editor1.EditorBodyStyle = "background-color:" + ((bgcol == null) ? string.Empty : bgcol);   
    11.   
    12.      }  
     

    Ken

  •  08-05-2009, 2:28 AM 54493 in reply to 54453

    Re: Dynamically set editor background colour VB Re Post 8845

    Fantastic Ken, Thanks.

    Can I add extra BodyStyles values like:
    Editor1.EditorBodyStyle = "background-color:" & bgcol & "font-color:" & fcol
  •  08-05-2009, 4:42 AM 54499 in reply to 54493

    Re: Dynamically set editor background colour VB Re Post 8845

    stevef,
     
    Sure, you can add extra bodystyles
     
    Ken
  •  08-05-2009, 5:19 AM 54502 in reply to 54499

    Re: Dynamically set editor background colour VB Re Post 8845

    Thanks (again) Ken,
    If I want to set the background and font color, what is the coding?
    Editor1.EditorBodyStyle = "background-color:" & bgcol & "font-color:" & fcol
  •  08-05-2009, 11:53 AM 54515 in reply to 54502

    Re: Dynamically set editor background colour VB Re Post 8845

    stevef:
    Thanks (again) Ken,
    If I want to set the background and font color, what is the coding?
    Editor1.EditorBodyStyle = "background-color:" & bgcol & "font-color:" & fcol
     
    Should be:
     
    Editor1.EditorBodyStyle = "background-color:" & bgcol & "color:" & fcol

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-06-2009, 1:34 AM 54543 in reply to 54515

    Re: Dynamically set editor background colour VB Re Post 8845

    Adam,
     
    Using:
    Editor1.EditorBodyStyle="background-color:" & bgcol & "color:" & fcol
    Results in NO background-color and No font color.
     
    Using:
    Editor1.EditorBodyStyle="background-color:" & bgcol
    Results in background-color set to variable bgcol.
  •  08-06-2009, 6:15 AM 54549 in reply to 54543

    Re: Dynamically set editor background colour VB Re Post 8845

    Hi stevef,
     
    Try
     
     Editor1.EditorBodyStyle = "background-color:" & bgcol & ";color:" & fcol
     
    Regards,
     
    Ken
View as RSS news feed in XML