📄 wizardpermission.ascx
字号:
}
DataControlRowType itemType = e.Row.RowType;
if ((itemType == DataControlRowType.Pager) ||
(itemType == DataControlRowType.Header) ||
(itemType == DataControlRowType.Footer))
{
return;
}
if (IsIE()) {
if (IsEntryDeleteable(e.Row.RowIndex)) {
// if netscape, then selecting the the row
// will not allow the DeleteRule to fire
foreach(Control c in e.Row.Cells[0].Controls) {
LinkButton button = c as LinkButton;
if (button == null) {
continue;
}
e.Row.Attributes["onclick"] = Page.GetPostBackClientHyperlink(button, "");
}
}
}
}
private string GetVirtualPath(string path) {
if (path == null) {
return null; // REVIEW: Should not happen.
}
return path.Substring("IIS://localhost/W3SVC/1/ROOT".Length);
}
private string GetDirectory(string path) {
if (path == null) {
return null;
}
if (path.LastIndexOf('/') == -1) {
return "/";
}
return path.Substring(path.LastIndexOf('/') + 1);
}
protected override void OnInit(EventArgs e) {
if(!IsPostBack) {
string appPath = (string)Session[APP_PATH];
TreeNode n = new TreeNode(GetDirectory(appPath), appPath);
tv.Nodes.Add(n);
n.Selected = true;
PopulateChildren(n, null);
CurrentPath = appPath;
}
if (!((WebAdminPage)Page).IsRoleManagerEnabled()) {
ListItem item = new ListItem((string)GetLocalResourceObject("RolesDisabled"));
roles.Items.Add(item);
roles.Enabled = false;
roleRadio.Enabled = false;
roleRadio.Checked = false;
userRadio.Checked = true;
base.OnInit(e);
return;
}
roles.DataSource = (string[]) ((WebAdminPage)Page).CallWebAdminHelperMethod(false, "GetAllRoles", new object[] {}, null);
roles.DataBind();
if (roles.Items.Count == 0) {
ListItem item = new ListItem((string)GetLocalResourceObject("NoRoles"));
roles.Items.Add(item);
roles.Enabled = false;
roleRadio.Enabled = false;
roleRadio.Checked = false;
userRadio.Checked = true;
}
base.OnInit(e);
}
public void Page_Load() {
Hashtable coll = ((WebAdminPage)Page).UserCollection;
if (coll != null && coll.Count > 0) {
bool first = true;
StringBuilder builder = new StringBuilder();
foreach(string s in coll.Keys) {
if (!first) {
builder.Append(",");
}
else {
first = false;
}
builder.Append(s);
}
userName.Text = builder.ToString();
((WebAdminPage)Page).ClearUserCollection();
}
BindGrid();
}
public void Page_Init() {
confirmation.DialogTitle.Text = (string)GetLocalResourceObject("DeleteRule");
confirmation.LeftButton.Click += new EventHandler(OK_Click);
confirmation.RightButton.Click += new EventHandler(Cancel_Click);
dataGrid.HeaderStyle.HorizontalAlign = DirectionalityHorizontalAlign;
}
private void PopulateChildren(TreeNode parent, string selectNodeValue) {
if (parent.ChildNodes.Count == 0) {
VirtualDirectory vdir = ((WebAdminPage)Page).GetVirtualDirectory(parent.Value);
foreach (VirtualDirectory childVdir in vdir.Directories) {
string childValue = parent.Value + "/" + childVdir.Name;
TreeNode newNode = new TreeNode(childVdir.Name, childValue);
if (selectNodeValue != null && childValue == selectNodeValue) {
//newNode.Selected = true;
newNode.SelectAction = TreeNodeSelectAction.Select;
}
parent.ChildNodes.Add(newNode);
}
}
}
private void SearchForUsers(object sender, EventArgs e) {
((WizardPage)Page).SaveActiveView();
Server.Transfer("../users/findusers.aspx");
}
private void SetItemColorRecursive(Control c, Color col) {
foreach(Control child in c.Controls) {
LinkButton button = child as LinkButton;
if (button != null) {
button.ForeColor = col;
}
Label label = child as Label;
if (label != null) {
label.ForeColor = col;
}
SetItemColorRecursive(child, col);
}
}
protected void TreeNodeExpanded(Object sender, TreeNodeEventArgs e) {
foreach(TreeNode child in e.Node.ChildNodes) {
PopulateChildren(child, null);
}
}
protected void TreeNodeSelected(object sender, EventArgs e) {
CurrentPath = ((TreeView)sender).SelectedNode.Value;
BindGrid();
}
public void UpdateRowColors(Control dataGrid, Control item) {
if (item == null) {
// unexpected condition -exit gracefully
return;
}
string prevItemID = (string)Session[SELECTED_ITEM];
if (prevItemID != null) {
GridViewRow prevItem = (GridViewRow) ((GridView)dataGrid).FindControl(prevItemID);
if (prevItem != null) {
// REVIEW
SetItemColorRecursive(prevItem, Color.Black);
// prevButton.ForeColor = Color.Black;
}
}
SetItemColorRecursive(item, Color.White);
// Review: best practice for a naming container inside a user control.
string id = item.UniqueID;
int i = id.IndexOf(((GridView)dataGrid).ID);
id = id.Substring(i);
i = id.IndexOf("$");
id = id.Substring(i + 1);
Session[SELECTED_ITEM] = id ;
}
private void UpdateRules() {
ArrayList rules = Rules;
Configuration config = ((WebAdminPage)Page).OpenWebConfiguration(CurrentPath, true);
AuthorizationSection auth = (AuthorizationSection) config.GetSection("system.web/authorization");
auth.Rules.Clear();
foreach (AuthorizationRule rule in rules) {
auth.Rules.Add(rule);
}
((WebAdminPage)Page).SaveConfig(config);
}
</script>
<asp:multiview runat="server" id="mv1" activeViewIndex="0">
<asp:view runat="server">
<table width=550 class="bodyTextNoPadding" cellpadding="0" cellspacing="0" border="0"><tr><td>
<asp:literal runat="server" text="<%$ Resources:Instructions %>"/>
</td></tr></table>
<br/>
<table cellspacing="0" width="550" cellpadding="5" class="lrbBorders">
<tr class="callOutStyle">
<td colspan="2"><asp:literal runat="server" text="<%$ Resources:AddNewAccessRule %>"/></td>
</tr>
<tr>
<td class="bodyTextNoPadding" width="36%" valign="top"><b><asp:literal runat="server" text="<%$ Resources:SelectDirForRule %>"/></b>
<table height="90%" cellspacing="0" cellpadding="4" rules="rows" bordercolor="#CCDDEF" border="0" style="border-color:#CCDDEF;border-style:None;width:100%;border-collapse:collapse;">
<tr >
<td width="200px" >
<asp:panel runat="server" id="panel1" scrollbars="auto" height="150px" width="200px" cssclass="bodyTextNoPadding">
<asp:treeview runat="server" id="tv" onTreeNodeExpanded="TreeNodeExpanded" onSelectedNodeChanged="TreeNodeSelected" >
<RootNodeStyle ImageUrl="../../images/folder.gif" />
<ParentNodeStyle ImageUrl="../../images/folder.gif" />
<LeafNodeStyle ImageUrl="../../images/folder.gif" />
<nodestyle cssclass="bodyTextLowPadding"/>
<selectednodestyle cssclass="bodyTextLowPaddingSelected"/>
</asp:treeview>
</asp:panel>
</td>
</tr>
</table>
</td>
<td height="100%" valign="top">
<table height="90%" border="0" cellpadding="6" cellspacing="0" class="bodyTextNoPadding" height="100%" width="100%" align="middle">
<tr>
<td width="50%" valign="top" ><b><asp:literal runat="server" text="<%$ Resources:RuleAppliesTo %>"/></b></td>
<td valign="top"><b><asp:literal runat="server" text="<%$ Resources:Permission %>"/>:</b></td>
</tr>
<tr>
<td width="62%" valign="top" bgcolor="#EEEEEE">
<asp:radiobutton runat="server" id="roleRadio" checked="true" enableviewstate="false" groupname="rolesUsers" />
<asp:label runat="server" associatedcontrolid="roleRadio"><asp:literal runat="server" text="<%$ Resources:Role %>"/></asp:label>
<asp:dropdownlist runat="server" id="roles" enableviewstate="false" style="position:relative; top:2"/>
</td>
<td valign="top" >
<asp:radiobutton runat="server" id="grantRadio" groupname="grantDeny" />
<asp:label runat="server" associatedcontrolid="grantRadio"><asp:literal runat="server" text="<%$ Resources:Allow %>"/></asp:label></td>
</tr>
<tr>
<td width="62%" valign="top" bgcolor="#EEEEEE">
<asp:radiobutton runat="server" id="userRadio" enableviewstate="false" groupname="rolesUsers" />
<asp:label runat="server" associatedcontrolid="userRadio"><asp:literal runat="server" text="<%$ Resources:User %>"/></asp:label>
<asp:textbox runat="server" id="userName" style="position:relative; left:10" size="12"/>
</td>
<td valign="top">
<%--<input type="radio" checked="checked" name="R1" onclick="javascript:nyiAlert()">--%>
<asp:radioButton runat="server" id="denyRadio" checked="true" groupName="grantDeny"/>
<asp:label runat="server" associatedcontrolid="denyRadio"><asp:literal runat="server" text="<%$ Resources:Deny %>"/></asp:label></td>
</tr>
<tr>
<td width="62%" valign="top" bgcolor="#EEEEEE">
<asp:radiobutton runat="server" id="allUsersRadio" groupname="rolesUsers" />
<asp:label runat="server" associatedcontrolid="allUsersRadio"><asp:literal runat="server" text="<%$ Resources:AllUsers %>"/></asp:label></td>
<td> </td>
</tr>
<tr>
<td width="62%" valign="top" bgcolor="#EEEEEE">
<asp:radiobutton runat="server" id="anonymousUsersRadio" groupname="rolesUsers" />
<asp:label runat="server" associatedcontrolid="anonymousUsersRadio"><asp:literal runat="server" text="<%$ Resources:AnonymousUsers %>"/></asp:label></td>
<td valign="bottom"><asp:button runat=server id="add" onClick="AddRule" text="<%$ Resources:AddThisRule %>"/></td>
</tr>
<tr><td><asp:linkbutton runat="server" onclick="SearchForUsers" text="<%$ Resources:SearchForUsers %>"/></td></tr>
</table>
</td>
</tr>
</table>
<asp:customvalidator runat="server" id="placeholderValidator" enableclientscript="false" errormessage="<%$ Resources:InvalidInput %>" display="dynamic"/>
<br/>
<span class="bodyTextNoPadding"><asp:literal runat="server" text="<%$ Resources:DimmedRules %>"/>
</span>
<br/><br/>
<asp:gridview runat="server" id="dataGrid" class="lrbBorders" width="550" allowsorting="true" gridlines="Horizontal" borderstyle="None" cellpadding="5" autogeneratecolumns="False" onrowdatabound="ItemDataBound" UseAccessibleHeader="true">
<rowstyle cssclass="gridRowStyle" />
<alternatingrowstyle cssclass="gridAlternatingRowStyle" />
<headerstyle cssclass="callOutStyle" font-bold=true />
<selectedrowstyle cssclass="gridSelectedRowStyle"/>
<columns>
<asp:templatefield headertext="<%$ Resources:Permission %>">
<itemtemplate>
<asp:label runat="server" id="select" enabled="<%# IsEntryDeleteable(((GridViewRow) Container).RowIndex) %>" forecolor="<%# ((GridViewRow) Container).RowIndex < Rules.Count - ParentRuleCount ? Color.Black : Color.Gray %>" text="<%#GetAction((AuthorizationRule)Container.DataItem)%>"/>
</itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="<%$ Resources:UsersAndRoles %>">
<itemtemplate>
<asp:label runat="server" enabled="<%# IsEntryDeleteable(((GridViewRow) Container).RowIndex) %>" forecolor="black" text="<%#GetUsersAndRoles((AuthorizationRule)Container.DataItem, true)%>"/>
</itemtemplate>
</asp:templatefield>
<asp:templatefield headertext="<%$ Resources:Delete %>">
<itemtemplate>
<asp:linkbutton runat="server" id="delete" enabled="<%# IsEntryDeleteable(((GridViewRow) Container).RowIndex) %>" forecolor='black' onClick="DeleteRule" text="<%$ Resources:Delete %>" toolTip='<%# GetToolTip("Delete",GetUsersAndRoles((AuthorizationRule)Container.DataItem, false)) %>' />
</itemtemplate>
</asp:templatefield>
</columns>
<pagerstyle forecolor="#000000" backcolor="#EEEEEE"/>
<pagersettings mode="Numeric"/>
</asp:gridview>
<asp:panel id=instructions/>
</asp:panel>
<br/>
</asp:view>
<asp:view runat="server">
<user:confirmation runat="server" id="confirmation"/>
</asp:view>
</asp:multiview>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -