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

Change font color based on user roles

1 Answer 128 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Afendi Hamat
Top achievements
Rank 1
Afendi Hamat asked on 19 Jun 2009, 03:31 PM
Hi all,
I'm building a simple annotation system using radeditor. what i have done so far (using the examples given in the documentation) is create a button that allows users to add their own notes to the existing text (using the fire command to change the appearance of fonts etc). These 'notes' look different from the original text but users would still need to click on the button provided before they start typing their notes.

What i would like to do is to detect the user role and when he types into the editor, the font color is automatically different from the original text. The idea is to let the font color change without the user clicking the button.

Hope i've been clear enough on the problem. Any idea how this might be achieved?
Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 24 Jun 2009, 12:31 PM
Hi Afendi,

Here is an example on how to set the text color depending on the user role through the codebehind:

    protected void Page_Load(object sender, EventArgs e) 
    { 
        string userRole = "Admin"
         
        //make a check for the user role and depending on its status set the desired text color  
        string script = @"
        <script language ='javascript'>
        function OnClientLoad(editor)
        {
                var style = editor.get_contentArea().style; 
                style.color = 'red'; 
                style.fontSize = '30px';
                style.fontName = 'Tahoma';
        }
        </script>"
 
        Page.ClientScript.RegisterClientScriptBlock(GetType(), "CommentScript", script, false); 
        RadEditor1.OnClientLoad = "OnClientLoad";  
    } 

Using the Page.RegisterClientScriptBlock server method you can import client script to the page from the server.

All the best,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Afendi Hamat
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or