I have a project with 2 types of users. I want only the Supervisors to be able to view the "User Management" page. This page is a child node of my rad menu and it seems that I can only hide the title node or I get this error:
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
How do I hide just some of the pages in the child nodes?
<siteMapNode title="Users" roles="Supervisor" target="_blank">
<siteMapNode url="UsersOnline.aspx" title="Users Online" target="_blank" />
<siteMapNode url="UserManagement.aspx" title="User Management" target="_blank" />
</siteMapNode>
Protected Sub RadMenu1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles RadMenu1.ItemDataBound
Dim node As SiteMapNode = TryCast(e.Item.DataItem, SiteMapNode)
If Not String.IsNullOrEmpty(node("target")) Then
e.Item.Target = node("target")
End If
If e.Item.Text = "User Management" AndAlso msUserType = "Standard" Then
RadMenu1.Items.Remove(e.Item)
End If
End Sub
| <telerik:RadGrid ID="grvUsers" |
| runat="server" |
| AutoGenerateColumns="False" |
| GridLines="None" |
| Skin="Office2007" |
| OnNeedDataSource="grvUsers_NeedDataSource" |
| OnUpdateCommand="grvUsers_UpdateCommand" |
| AllowPaging="True" |
| AllowSorting="True" |
| ShowGroupPanel="True" OnItemCommand="grvUsers_ItemCommand" OnEditCommand="grvUsers_EditCommand"> |
| <MasterTableView AllowAutomaticInserts="True" CommandItemDisplay="Top"> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn Resizable="False" Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridEditCommandColumn> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" UniqueName="LastName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" UniqueName="FirstName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="UserLevel" HeaderText="User Rights" UniqueName="Rights"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Enabled" HeaderText="Enabled" UniqueName="Enabled"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="UserInfoUID" UniqueName="UserInfoUID" Visible="False"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="UserName" UniqueName="UserName" Visible="False"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings EditFormType="Template" CaptionFormatString="Edit the information for <%# Bind('FirstName') %> <%# Bind('LastName') %>" > |
| <EditColumn UniqueName="EditCommandColumn1"></EditColumn> |
| <FormTemplate> |
| <table style="width: 568px"> |
| <tr> |
| <td style="width: 131px"> |
| Last Name</td> |
| <td style="width: 160px"> |
| <telerik:RadTextBox ID="txtEdit_LastName" runat="server" MaxLength="50" Text="<%# Bind('LastName') %>"> |
| </telerik:RadTextBox></td> |
| <td> |
| <asp:RequiredFieldValidator ID="rfvEdit_LastName" runat="server" ControlToValidate="txtEdit_LastName" |
| ErrorMessage="Please enter the users last name" ValidationGroup="Edit">*</asp:RequiredFieldValidator> |
| </td> |
| <td style="width: 174px"> |
| First Name</td> |
| <td style="width: 156px"> |
| <telerik:RadTextBox ID="txtEdit_FirstName" runat="server" MaxLength="50" Text="<%# Bind('FirstName') %>"> |
| </telerik:RadTextBox></td> |
| <td> |
| <asp:RequiredFieldValidator ID="rfvEdit_FirstName" runat="server" ControlToValidate="txtEdit_FirstName" |
| ErrorMessage="Please enter the users first name" ValidationGroup="Edit">*</asp:RequiredFieldValidator></td> |
| </tr> |
| <tr> |
| <td style="width: 131px"> |
| Username</td> |
| <td style="width: 160px"> |
| <telerik:RadTextBox ID="txtEdit_Username" runat="server" Text="<%# Bind('Username') %>"> |
| </telerik:RadTextBox></td> |
| <td> |
| <asp:RequiredFieldValidator ID="rfvEdit_UserName" runat="server" ControlToValidate="txtEdit_Username" |
| ErrorMessage="Please enter the users 'Username'" ValidationGroup="Edit">*</asp:RequiredFieldValidator></td> |
| <td style="width: 174px"> |
| </td> |
| <td style="width: 156px"> |
| </td> |
| <td> |
| </td> |
| </tr> |
| <tr> |
| <td style="width: 131px; height: 27px"> |
| Password</td> |
| <td style="width: 160px; height: 27px"> |
| <telerik:RadTextBox ID="txtEdit_Password" runat="server" InvalidStyleDuration="100" Text="<%# Bind('Password') %>" Width="125px" EmptyMessage="************" MaxLength="20" TextMode="Password"> |
| </telerik:RadTextBox></td> |
| <td style="height: 27px"> |
| </td> |
| <td style="width: 174px; height: 27px"> |
| Password</td> |
| <td style="height: 27px; width: 156px;"> |
| <telerik:RadTextBox ID="txtEdit_ConfirmPassword" runat="server" InvalidStyleDuration="100" Text="<%# Bind('Password') %>" TextMode="Password" Width="125px" EmptyMessage="***********" MaxLength="20"> |
| </telerik:RadTextBox> |
| </td> |
| <td style="height: 27px"> |
| </td> |
| </tr> |
| <tr> |
| <td> |
| Rights</td> |
| <td> |
| <asp:DropDownList ID="cmbEdit_Rights" runat="server" Width="119px" SelectedValue='<%# Bind("UserLevel") %>'> |
| <asp:ListItem>User</asp:ListItem> |
| <asp:ListItem>Admin</asp:ListItem> |
| </asp:DropDownList></td> |
| <td> |
| </td> |
| <td> |
| Enabled</td> |
| <td> |
| <asp:DropDownList ID="cmbEdit_Enabled" runat="server" Width="119px" SelectedValue='<%# Bind("Enabled") %>'> |
| <asp:ListItem Value="True">Yes</asp:ListItem> |
| <asp:ListItem Value="False">No</asp:ListItem> |
| </asp:DropDownList></td> |
| <td> |
| </td> |
| </tr> |
| <tr> |
| <td colspan="6"> |
| </td> |
| </tr> |
| <tr> |
| <td align="right" colspan="6"> |
| <asp:LinkButton ID="lnkEdit_Cancel" runat="server" CausesValidation="False" CommandName="Cancel" Text='<%# (Container is GridEditFormInsertItem) ? "Done" : "Cancel" %>' >Cancel</asp:LinkButton> |
| <asp:LinkButton ID="lnkEdit_Done" runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' Text='<%# (Container is GridEditFormInsertItem) ? "Save" : "Save Changes" %>'></asp:LinkButton> |
| |
| </td> |
| </tr> |
| <tr> |
| <td align="center" colspan="6"> |
| <asp:Label ID="lblUID" runat="server" Text="<%# Bind('UserInfoUID') %>" Visible="False"></asp:Label> |
| <asp:Label ID="lblEdit_Message" runat="server"></asp:Label> |
| </td> |
| </tr> |
| <tr> |
| <td align="center" colspan="6" style="height: 21px"> |
| <asp:ValidationSummary ID="vsEdit" runat="server" ValidationGroup="Edit" /> |
| </td> |
| </tr> |
| </table> |
| </FormTemplate> |
| <PopUpSettings ScrollBars="None" /> |
| </EditFormSettings> |
| <CommandItemSettings AddNewRecordText="Add new user" /> |
| <PagerStyle AlwaysVisible="True" HorizontalAlign="Left" Mode="Slider" /> |
| </MasterTableView> |
| <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" AllowDragToGroup="True"> |
| <Selecting AllowRowSelect="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| <asp:DropDownList ID="cmbEdit_Enabled" runat="server" Width="119px" SelectedValue='<%# Bind("Enabled") %>'> |
| <asp:ListItem Value="True">Yes</asp:ListItem> |
| <asp:ListItem Value="False">No</asp:ListItem> |
| </asp:DropDownList> |
| <telerik:RadDataPager ID="UnlocatedCasesPager" |
| runat="server" |
| PagedControlID="UnlocatedCasesListView" |
| PageSize="4"> |
| <Fields> |
| <telerik:RadDataPagerButtonField FieldType="FirstPrev" /> |
| <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="3" /> |
| <telerik:RadDataPagerButtonField FieldType="NextLast" /> |
| </Fields> |
| </telerik:RadDataPager> |
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function OnClientDropDownClosing(sender, args) {
// if (args.get_node().get_level() == 0)
// {
// args.set_cancel(true);
// }
// else {
var item = sender.get_items().getItem(0); // Get the first RadComboBoxItem
var treeView = item.findControl('tvDepartments'); // Find your RadTreeView
var checkedNodes = treeView.get_checkedNodes(); // Retrieve the checked items in the RadTreeView
var newText = '';
checkedNodes.forEach(function (node) { // Loop through the checked nodes. Requires jQuery!
if (newText != '') { newText += ', '; }
newText += node.get_text();
});
var comboBox = $find("<%= cbxDepartments.ClientID %>");
comboBox.set_text(newText); // Set the RadComboBox text
if ($.browser.msie) { // IE sometimes takes two tries for it to respond to new text
comboBox.set_text(newText);
// }
}
}
</script>
<telerik:RadComboBox ID="cboProvinciaT" runat="server" Width="200px" OnClientSelectedIndexChanging="LoadLocalidades" OnItemsRequested="cboProvinciaT_ItemsRequested" MarkFirstMatch="true" Skin="Sunset"></telerik:RadComboBox><telerik:RadComboBox ID="cboLocalidadT" runat="server" Width="200px" OnClientSelectedIndexChanging="LoadTiposVia" OnClientItemsRequested="ItemsLoaded" OnItemsRequested="cboLocalidadT_ItemsRequested" MarkFirstMatch="true" Skin="Sunset"></telerik:RadComboBox><telerik:RadComboBox ID="cboTipoViaT" runat="server" Width="80px" OnClientSelectedIndexChanged="LoadNombresVia" OnClientItemsRequested="ItemsLoaded" OnItemsRequested="cboTipoViaT_ItemsRequested" MarkFirstMatch="true" Skin="Sunset"></telerik:RadComboBox><telerik:RadComboBox ID="cboNombreVia" runat="server" OnClientItemsRequested="ItemsLoaded" OnItemsRequested="cboNombreVia_ItemsRequested" Filter="Contains" Skin="Sunset"></telerik:RadComboBox><script type="text/javascript"> var LocalidadesCombo; var TiposViaCombo; var NombresVia; function pageLoad() { LocalidadesCombo = $find("<%= cboLocalidadT.ClientID %>"); TiposViaCombo = $find("<%= cboTipoViaT.ClientID %>"); NombresVia = $find("<%= cboNombreVia.ClientID %>"); } function LoadLocalidades(sender, eventArgs) { var item = eventArgs.get_item(); LocalidadesCombo.set_text("Cargando..."); TiposViaCombo.clearSelection(); if (item.get_index() > 0) { LocalidadesCombo.requestItems(item.get_value(), false); LocalidadesCombo.clearSelection(); } else { LocalidadesCombo.set_text(" "); LocalidadesCombo.clearItems(); TiposViaCombo.set_text(" "); TiposViaCombo.clearItems(); } } function LoadTiposVia(sender, eventArgs) { var item = eventArgs.get_item(); TiposViaCombo.set_text("Cargando..."); TiposViaCombo.requestItems(item.get_value(), false); TiposViaCombo.clearSelection(); if (item.get_index() > 0) { TiposViaCombo.requestItems(item.get_value(), false); TiposViaCombo.clearSelection(); } else { TiposViaCombo.set_text(" "); TiposViaCombo.clearItems(); NombresVia.set_text(" "); NombresVia.clearItems(); } } function LoadNombresVia(sender, eventArgs) { var item = eventArgs.get_item(); NombresVia.set_text("Cargando..."); NombresVia.requestItems(item.get_value(), false); NombresVia.clearSelection(); } function ItemsLoaded(sender, eventArgs) { sender.showDropDown(); }</script>if (!Page.IsPostBack){ CargarProvincias(); //This method fill cboProvinciaT}else if (!Page.IsCallback){ LoadLocalidades(cboProvinciaT.SelectedValue); LoadTiposVia(cboLocalidadT.SelectedValue); LoadNombresVia(cboTipoViaT.SelectedValue);}#region Direcciónprotected void LoadLocalidades(string pIdProvincia){ try { AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, 'Localidad...' as Nombre union SELECT ID, Nombre FROM tlLocalidadDN where idProvincia=" + pIdProvincia + " ORDER BY Nombre ASC"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboLocalidadT.DataTextField = "Nombre"; cboLocalidadT.DataValueField = "ID"; cboLocalidadT.DataSource = mDS.Tables[0]; cboLocalidadT.DataBind(); } catch (Exception ex) { throw ex; } }protected void LoadTiposVia(string pIdLocalidad){ try { AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, 'VÃa..' as Nombre union SELECT ID, Nombre FROM tlTipoViaDN ORDER BY Nombre ASC"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboTipoViaT.DataTextField = "Nombre"; cboTipoViaT.DataValueField = "ID"; cboTipoViaT.DataSource = mDS.Tables[0]; cboTipoViaT.DataBind(); } catch (Exception ex) { throw ex; }}protected void LoadNombresVia(string pIdTipoVia){ try { //HERE ALWAYS GET empty ("")
string mIdLocalidad = cboLocalidadT.SelectedValue;
AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, ' Nombre de la VÃa..' as Nombre union SELECT ID, Nombre FROM tlViaDN where idLocalidad=" + mIdLocalidad + " and idTipovia=" + pIdTipoVia + " order by Nombre"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboNombreVia.DataTextField = "Nombre"; cboNombreVia.DataValueField = "ID"; cboNombreVia.DataSource = mDS.Tables[0]; cboNombreVia.DataBind(); } catch (Exception ex) { throw ex; }}protected void LoadNombresVia(string pIdTipoVia, string pIdLocalidad){ try { AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, ' Nombre de la VÃa..' as Nombre union SELECT ID, Nombre FROM tlViaDN where idLocalidad=" + pIdLocalidad + " and idTipovia=" + pIdTipoVia + " order by Nombre"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboNombreVia.DataTextField = "Nombre"; cboNombreVia.DataValueField = "ID"; cboNombreVia.DataSource = mDS.Tables[0]; cboNombreVia.DataBind(); } catch (Exception ex) { throw ex; }}protected void cboNombreVia_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ LoadNombresVia(e.Text);}protected void cboProvinciaT_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ CargarProvincias();}protected void cboLocalidadT_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ LoadLocalidades(e.Text);}protected void cboTipoViaT_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ LoadTiposVia(e.Text);}#endregionprotected void LoadNombresVia(string pIdTipoVia) { try { //******************************************** //**** HERE ALWAYS GET EMPTY VALUE --> "" **** //******************************************** string mIdLocalidad = cboLocalidadT.Text; //******************************************** AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, ' Nombre de la VÃa..' as Nombre union SELECT ID, Nombre FROM tlViaDN where idLocalidad=" + mIdLocalidad + " and idTipovia=" + pIdTipoVia + " order by Nombre"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboNombreVia.DataTextField = "Nombre"; cboNombreVia.DataValueField = "ID"; cboNombreVia.DataSource = mDS.Tables[0]; cboNombreVia.DataBind(); } catch (Exception ex) { throw ex; } }<asp:panel id="div_projectsAssigned" runat="server" class="infoBox-projectsAssigned"> <telerik:RadTextBox ID="txtProjectsAssigned" runat="server" Text="0" BorderStyle="None" ReadOnly="True" Width="42" > <ClientEvents OnValueChanged="onValueChanged()" /> <ReadOnlyStyle HorizontalAlign="Center" BackColor="Transparent" ForeColor="White" Font-Bold="True" Font-Names="Segoe UI" Font-Size="12pt" Width="30px"> </ReadOnlyStyle> </telerik:RadTextBox></asp:panel>ClientEvents OnValueChanged="onValueChanged()" />
<script type="text/javascript"> function onValueChanged(sender, args) { if (args.get_oldvalue != args.get_newvalue) { thisDiv = $get("<%= div_projectsAssigned.ClientID %>"); esteDiv = "#" + thisDiv; animateDiv(thisDiv); } } function animateDiv(divToAnimate) { for (i = 1; i <= 3; i++) { $(divToAnimate).animate( { "opacity": "0.15" }, "slow"); $(divToAnimate).animate( { "opacity": "1.00" }, "slow"); } } </script>