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

[Solved] Context.User.IsInRole

1 Answer 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jose
Top achievements
Rank 2
Jose asked on 29 Oct 2010, 06:32 PM
Hello,

How could I to check for Context.User.IsInRole inside a clientemplate?
I've tried with the next code but it doesn't work:

.ClientTemplate(
                                "<# if (!QuotationSend || Context.User.IsInRole('Administrator')) { #>" +
                                    "<a href='/Quotations/Edit/<#= QuotationId #>'>" +
                                    "<img class='NoBorderImg' alt='Edit' src='" + Url.Content("../../Images/Edit.png") + "' />" +
                                    "</a>" +
                                "<# } #>"
                                )

Regards
Jose

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 01 Nov 2010, 07:54 AM
Hi Jose,

 You cannot run server side code on the client-side. It is just not impossible. What you can do is serialize the value of that method in a JavaScript variable (before the grid declaration):

<script type="text/javascript">
var isAdministrator = <%=Context.User.IsInRole("Administrator") %>
</script>

Then use that variable:
.ClientTemplate("<# if (isAdministrator) #>" + ...
)

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Jose
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Share this question
or