Im new to asp.mvc. Tôi đang cố gắng phát triển một cổng để duy trì dữ liệu của nhân viên. Trong hệ thống của tôi chỉ "Quản lý" có rigths để tạo ra nhân viên. Làm thế nào để bật liên kết khi quản lý đăng nhập và vô hiệu hóa khi người lao động đăng nhập. Cảm ơnẨn liên kết dựa trên Vai trò
Xem My
@model IEnumerable<SealManagementPortal_3._0.Models.VOC_CUSTODIAN>
@{
ViewBag.Title = "List of Custodians";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#list2").jqGrid({
url: '@Url.Action("GridData", "Custodian")',
datatype: 'json',
mtype: 'GET',
colNames: ['Agent ID', 'Branch', 'Unique ID', 'Custodian Name', /*'NRIC No', 'E-Mail', 'Contact No', 'Mobile No',*/'Role', 'Details', 'Edit', 'Delete'],
colModel: [
{ name: 'Agent ID', index: '', width: 10, align: 'left' },
{ name: 'Branch', index: '', width: 10, align: 'left' },
{ name: 'Unique ID', index: '', width: 10, align: 'left' },
{ name: 'Custodian Name', index: '', width: 10, align: 'left' },
{name: 'Role', index: '', width: 10, align: 'left' },
{ name: 'Details', index: '', width: 5, align: 'left' },
{ name: 'Edit', index: '', width: 5, align: 'left' },
{ name: 'Delete', index: '', width: 5, align: 'left'}],
pager: jQuery('#pager2'),
rowNum: 10,
sortname: 'Id',
sortorder: "desc",
viewrecords: true,
autowidth: true,
caption: 'Custodians List'
});
});
</script>
@using (Html.BeginForm())
{
<table id="list2" class="scroll" cellpadding="0" cellspacing="0"></table>
Có cách nào để tránh sự lặp lại của "Người quản lý" trong mẫu không? Tôi muốn có vai trò quản lý ở một nơi và thuộc tính Authorize rất tốt với tôi. Tôi có thể xác định bằng cách nào đó một HtmlHelper truy cập nội dung của thuộc tính? –