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.
精彩评论