开发者

Show TinyMCE when use is logged in otherwise not

开发者 https://www.devze.com 2023-03-14 10:58 出处:网络
I want TinyMCE applied on a TextArea when user role is admin otherwise show normal TextArea. How开发者_JAVA百科 do I do that?

I want TinyMCE applied on a TextArea when user role is admin otherwise show normal TextArea.

How开发者_JAVA百科 do I do that?

Is there TinyMCE server side command for that?


You can check the current user's membership in a role and then enable TinyMCE for a given textarea with this sort of approach:

@if (HttpContext.Current.User.IsInRole("Administrator")) {

    <script type="text/javascript">
        $(function() {
            $('#mytextarea').tinymce({
                // tinymce config
            });
        });
    </script>

}

You may also want to do the role check in your controller and pass the value as part of a ViewModel or the ViewBag.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号