开发者

Show TinyMCE when use is logged in otherwise not

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜