The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

8 posts, 0 answers
  1. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 01 Aug 2013 Link to this post

    In my aspx page, when user click a "Preview" button in radtoolbar it will redirect to another page with querystring. but i get the following error

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    I had already tried to use both scriptblock and codeblock, but it doen't work

    <%@ Page Title="" Language="VB" MasterPageFile="~/LRDB.master" AutoEventWireup="false" CodeFile="SIMPER_details.aspx.vb" Inherits="TrainingAdmin_SIMPER_details" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
           .table_photo
            {
                width: 100px;
                height: auto;
            }
     
          .table_content
          {
              width: 400px;
              }
                 
                .table_header
                {
                    width: 282px;
                    height: 15px;
                    background-color: #E7EEF6;
                }
                 
           .style6
        {
            width: 392px;
            height: 15px;
            background-color: #E7EEF6;
            font-weight: 700;
        }
                 
           </style>
    </asp:Content>
     
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
           <script type="text/javascript">
               //        var lastClickedItem = null;
               //        var clickCalledAfterRadprompt = false;
               //        var clickCalledAfterRadconfirm = false;
               //        function onClientButtonClicking(sender, args) {
               //            if (args.get_item().get_text() == "Create SIMPER") {
               //                if (!clickCalledAfterRadconfirm) {
               //                    args.set_cancel(true);
               //                    lastClickedItem = args.get_item();
               //                    radconfirm("Are you sure you want to create?", confirmCallbackFunction);
               //                }
               //            }
               //            else if (args.get_item().get_text() == "Delete") {
               //                if (!clickCalledAfterRadconfirm) {
               //                    args.set_cancel(true);
               //                    lastClickedItem = args.get_item();
               //                    radconfirm("Are you sure you want to delete?", confirmCallbackFunction);
               //                }
               //            }
     
               //        }
     
               //        function confirmCallbackFunction(args) {
               //            if (args) {
               //                clickCalledAfterRadconfirm = true;
               //                lastClickedItem.click();
               //            }
               //            else
               //                clickCalledAfterRadconfirm = false;
               //            lastClickedItem = null;
               //        }
     
               //        OnClientButtonClicking = "onClientButtonClicking"
     
               function ShowSIMPER(id) {
                   var wnd = window.radopen("SIMPER_view.aspx?SIMPER_ID=" + id + "&UserID=0", "SIMPER_PDF");
                   wnd.SetSize("700", "700");
                   wnd.moveTo("250", "140");
                   //return false;
               }
            </script>
        </telerik:RadScriptBlock>
     
     
     
        <telerik:RadWindowManager runat="server" ID="rwm1">
        </telerik:RadWindowManager>
         
     
     
        <%--<telerik:RadToolBar ID="RadToolBar1" runat="server" Width="100%" Skin="Windows7" OnClientButtonClicking="onClientButtonClicking" >--%>
     
        <telerik:RadToolBar ID="rtbMenu" runat="server" Width="100%" Skin="Windows7">
            <Items>
                <telerik:RadToolBarButton Value="Preview" Text="Preview SIMPER" Width="150px" Enabled="false"  />
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="Refresh" Text="Refresh" Width="80px"  CausesValidation="false" />
                <telerik:RadToolBarButton IsSeparator="true" />
                <telerik:RadToolBarButton Value="Back" Text="Back" Width="80px"  CausesValidation="false"/>
                <telerik:RadToolBarButton Value="BackSeparator" IsSeparator="true" />
            </Items>
        </telerik:RadToolBar>
        <telerik:RadFormDecorator ID="RpFormDecorator" runat="server" Skin="Windows7" DecoratedControls="All" EnableRoundedCorners="true" /> 
     
       
     
     
               <div id="content_function" class="content_function" >
     
     
       
     
     
                                  <div style="margin-left:5px;">
                                  <table cellpadding="1" width="1000" style="vertical-align:top">
                                  <tr>
                                  <td align="left" valign="top" class="style6">Name
                                  </td>
                                  <td align="left" valign="top" class="table_content">
                                  <asp:Label ID="lb_name" runat="server"></asp:Label>
                                  </td>
                                  <td align="left" valign="top" class="table_content" rowspan="8">
                                    <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" ImageUrl="../images/blank_photo.jpg"
                                                   Width="100px" ResizeMode="Fit" AlternateText="No picture available" style="border-style:dotted;"
                                                   CssClass="preview" AutoAdjustImageControlSize="false"></telerik:RadBinaryImage>
                                                         </td>
                                  </tr>
                                  <tr>
                                  <td align="left" valign="top" class="style6">Gender
                                  </td>
                                  <td align="left" valign="top" class="table_content">
                                  <asp:Label ID="lb_gender" runat="server"></asp:Label>
                                  </td>
                                  </tr>                             
                                  <tr>
                                  <td align="left" valign="top" class="style6">Department
                                  </td>
                                  <td align="left" valign="top" class="table_content">
                                  <asp:Label ID="lb_dept" runat="server"></asp:Label>
                                  </td>
                                  </tr>
                                   
                                  <tr>
                                  <td align="left" valign="top" class="style6"> </td>
                                  <td align="left" valign="top" class="table_content">
                                       </td>
                                  </tr>
                                   
                                  <tr>
                                  <td align="left" valign="top" class="style6"><span class="style4">Required
                                      information if create SIMPER:</span> </td>
                                  <td align="left" valign="top" class="table_content">
                                       </td>
                                  </tr>
                                   
                                  <tr>
                                  <td align="left" valign="top" class="style6">Valid From<br />
                                      </td>
                                  <td align="left" valign="top" class="table_content">
                                      <telerik:RadDatePicker ID="RadDatePicker_ValidFrom" Runat="server"
                                          Culture="en-US" MinDate="1/1/1900">
                                      </telerik:RadDatePicker>
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter Valid From." ControlToValidate="RadDatePicker_ValidFrom"></asp:RequiredFieldValidator>
                                  </td>
                                  </tr>
                                   
                                  <tr>
                                  <td align="left" valign="top" class="style6">Valid Till<br />
                                      </td>
                                  <td align="left" valign="top" class="table_content">
                                      <telerik:RadDatePicker ID="RadDatePicker_ValidTill" Runat="server" 
                                          Culture="en-US" MinDate="1/1/1900">
     
                                      </telerik:RadDatePicker>
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter Valid Till." ControlToValidate="RadDatePicker_ValidTill"></asp:RequiredFieldValidator>
                                      <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="RadDatePicker_ValidTill" ControlToCompare="RadDatePicker_ValidFrom"
                                        Operator="GreaterThanEqual" Type="Date" ErrorMessage="Valid Till date must be equal or greater than Valid From date - please correct dates." Display="Dynamic">
                                    </asp:CompareValidator>
                                  </td>
                                  </tr>
                                   
                                  </table>
                                  <br />
                                      <br />
                                      License Obtained<br />
                                      <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="LDS_License"
                                          AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" PageSize="20"
                                          CellSpacing="0" GridLines="None" Width="1000">
                                    <MasterTableView DataSourceID="LDS_License" AutoGenerateColumns="False" DataKeyNames="License_To_Operate_ID" OverrideDataSourceControlSorting="true">
                                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
                                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                    </RowIndicatorColumn>
     
                                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                    </ExpandCollapseColumn>
     
                                        <Columns>
     
                                            <telerik:GridBoundColumn DataField="db_dictionary_license.license_type"
                                                FilterControlAltText="Filter License_Number column" HeaderText="License Type"
                                                SortExpression="db_dictionary_license.license_type" UniqueName="license_type">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="db_dictionary_license.license_name"
                                                FilterControlAltText="Filter License Name column" HeaderText="License Name"
                                                SortExpression="db_dictionary_license.license_name" UniqueName="license_name">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="License_Number"
                                                FilterControlAltText="Filter License_Number column" HeaderText="License Number"
                                                SortExpression="License_Number" UniqueName="License_Number">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="License_Issuer"
                                                FilterControlAltText="Filter License_Issuer column" HeaderText="License Issuer"
                                                SortExpression="License_Issuer" UniqueName="License_Issuer">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Valid_From" DataType="System.DateTime"
                                                FilterControlAltText="Filter Valid_From column" HeaderText="Valid From"
                                                SortExpression="Valid_From" UniqueName="Valid_From" DataFormatString="{0: dd-MMM-yyy}">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Valid_Till" DataType="System.DateTime"
                                                FilterControlAltText="Filter Valid_Till column" HeaderText="Valid Till"
                                                SortExpression="Valid_Till" UniqueName="Valid_Till" DataFormatString="{0: dd-MMM-yyy}">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Issue_date" DataType="System.DateTime"
                                                FilterControlAltText="Filter Issue_date column" HeaderText="Issue Date"
                                                SortExpression="Issue_date" UniqueName="Issue_date" DataFormatString="{0: dd-MMM-yyy}">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="License_ID" Display="false"
                                                FilterControlAltText="Filter License_ID column" HeaderText="License_ID"
                                                UniqueName="License_ID" AllowFiltering="false" >
                                            </telerik:GridBoundColumn>
     
                                        </Columns>
     
                                    <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                    </EditFormSettings>
     
                                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                    </MasterTableView>
     
                                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
     
                                    <FilterMenu EnableImageSprites="False"></FilterMenu>
                                                                      </telerik:RadGrid>
                                                                      <asp:LinqDataSource ID="LDS_License" runat="server" EntityTypeName=""
                                                                          ContextTypeName="dcLRDBDataContext" TableName="db_Employee_Licenses"
                                                                          Where="UserID == @UserID && tmpRecord != @tmpRecord">
                                                                          <WhereParameters>
                                                                              <asp:QueryStringParameter Name="UserID" QueryStringField="UserID"
                                                                                  Type="Int32" />
                                                                              <asp:Parameter DefaultValue="Y" Name="tmpRecord" Type="Char" />
                                                                          </WhereParameters>
                                                                      </asp:LinqDataSource>
     
                                                                      <br /><br /><br />
                                                                      Existing SIMPER Card<br />
                                                                      <telerik:RadGrid ID="RadGrid2" runat="server" AllowFilteringByColumn="True"
                                                                          AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"  OnItemCreated="RadGrid2_ItemCreated"
                                                                          CellSpacing="0" DataSourceID="LDS_SIMPER" GridLines="None" Width="400" onitemcommand="RadGrid2_ItemCommand">
                                                                          <ClientSettings EnablePostBackOnRowClick="true">
                                                <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> 
                                            </ClientSettings>
     
                                    <MasterTableView DataKeyNames="SIMPER_ID" DataSourceID="LDS_SIMPER">
                                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
     
                                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                    </RowIndicatorColumn>
     
                                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                    </ExpandCollapseColumn>
     
                                        <Columns>
                                                    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn" AllowFiltering="false">
                                                        <ItemTemplate>
                                                            <asp:HyperLink ID="ViewLink" runat="server" Text="View"></asp:HyperLink>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn DataField="Valid_From" DataType="System.DateTime"
                                                FilterControlAltText="Filter Valid_From column" HeaderText="Valid From"
                                                SortExpression="Valid_From" UniqueName="Valid_From" DataFormatString ="{0: dd-MMM-yyyy}">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Valid_Till" DataType="System.DateTime"
                                                FilterControlAltText="Filter Valid_Till column" HeaderText="Valid Till"
                                                SortExpression="Valid_Till" UniqueName="Valid_Till" DataFormatString ="{0: dd-MMM-yyyy}">
                                            </telerik:GridBoundColumn>
                                        </Columns>
     
                                    <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                    </EditFormSettings>
     
                                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
                                    </MasterTableView>
     
                                    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
     
                                    <FilterMenu EnableImageSprites="False"></FilterMenu>
                                                                      </telerik:RadGrid>
     
                                            <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
                                            <Windows>
                                                <telerik:RadWindow ID="SIMPER_PDF" runat="server" Title="View SIMPER Card" Height="700px"
                                                    Width="710px" Left="50px" ReloadOnShow="true" ShowContentDuringLoad="false" VisibleStatusBar="false"
                                                    Modal="false">
                                                </telerik:RadWindow>
                                            </Windows>
                                            </telerik:RadWindowManager>
     
                                                                      <asp:LinqDataSource ID="LDS_SIMPER" runat="server"
                                                                          ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                                          TableName="db_Employee_Simper_Records" Where="UserID == @UserID and parent_id == null">
                                                                          <WhereParameters>
                                                                              <asp:QueryStringParameter Name="UserID" QueryStringField="UserID"
                                                                                  Type="Int32" />
                                                                          </WhereParameters>
                                                                      </asp:LinqDataSource>
                                                                      <br />
     
                                                                  </div>
     
                                           </div>
                                           </asp:Content>

    Code Behind

    Imports Telerik.Web.UI
    Imports System.Collections
    Imports System
     
    Partial Class TrainingAdmin_SIMPER_details
        Inherits System.Web.UI.Page
        Private Shared prevPage As String = String.Empty
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                prevPage = Request.UrlReferrer.ToString()
                If Request.QueryString("UserID") <> String.Empty Then
                    Dim dc As New dcLRDBDataContext
                    Dim res = (From a In dc.db_Employee_Details _
                               Where a.UserID = Request.QueryString("UserID").ToString _
                               From b In dc.db_Departments _
                               .Where(Function(fb) fb.DeptID = a.Dept_ID) _
                               .DefaultIfEmpty() _
                               Select New With { _
                                   a.Employee_Display_Name, b.Department, a.Employee_ID, a.Gender, a.Photo _
                                                                      } _
                               ).FirstOrDefault
     
                    If Not IsNothing(res) Then
                        lb_name.Text = res.Employee_Display_Name
                        lb_dept.Text = res.Department
                        lb_gender.Text = res.Gender
                        If Not IsNothing(res.Photo) Then
                            RadBinaryImage1.DataValue = res.Photo.ToArray
                        End If
                    End If
     
                    'Dim res2 = (From a In dc.db_Dictionary_Licenses Where a.License_ID = Request.QueryString("LicenseID").ToString).FirstOrDefault
                    'If Not IsNothing(res2) Then
                    '    lb_license.Text = res2.License_Name
                    'End If
     
                    'staff_photo.Src = ConfigurationManager.AppSettings("PhotoPath") & GetEmployeeIDByUserID(Request.QueryString("UserID")).ToString & ".jpg"
                    'If System.IO.File.Exists(Server.MapPath(staff_photo.Src)) = True Then
                    '    staff_photo.Src = staff_photo.Src
                    'Else
                    '    staff_photo.Src = ConfigurationManager.AppSettings("PhotoPath") & "/blank_staff_photo.jpg"
                    'End If
     
                    dc.Dispose()
     
                End If
            End If
        End Sub
        Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick
            If e.Item.Value = "Back" Then
                Response.Redirect(prevPage)
                'Response.Redirect("~/TrainingAdmin/SIMPER.aspx")
            ElseIf e.Item.Value = "Create" Then
                If CreateSIMPER() = True Then
                    Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?UserID=" & Request.QueryString("UserID"))
                Else
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('Error! SIMPER Card cannot create.');", True)
                End If
            ElseIf e.Item.Value = "Preview" Then
                Dim url = "~/TrainingAdmin/SIMPER_view.aspx?SIMPER_ID=0&UserID=" & Request.QueryString("UserID") _
                          & "&From=" & RadDatePicker_ValidFrom.SelectedDate & "&To=" & RadDatePicker_ValidTill.SelectedDate
                'ScriptManager.RegisterStartupScript(Page, GetType(Page), "OpenWindow", _
                '                                    "window.open('" & url & "','_blank','status=0,toolbar=0,menubar=0,location=0,scrollbars=0,resizable=0,width=710,height=700');", True)
     
                Dim windowManager As New RadWindowManager()
                Dim window1 As New RadWindow()
                ' Set the window properties  
                window1.NavigateUrl = url
                window1.ID = "RadWindow1"
                window1.Height = 750
                window1.Width = 740
                window1.Top = 140
                window1.Left = 250
     
                window1.AutoSize = False
                window1.VisibleTitlebar = True
                window1.VisibleStatusbar = False
                window1.VisibleOnPageLoad = True
                ' Set this property to True for showing window from code  
                windowManager.Windows.Add(window1)
                Me.Form.Controls.Add(window1)
     
            ElseIf e.Item.Value = "Refresh" Then
                Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?userID=" & Request.QueryString("UserID"))
     
            End If
        End Sub
     
        Protected Function CreateSIMPER() As Boolean
            Dim confirm As Boolean = False
            Dim dc As New dcLRDBDataContext
     
            Dim simperid As Integer = 0
     
            If RadGrid1.Items.Count > 0 Then
                Dim newRecord1 As New db_Employee_Simper_Record
     
                dc.db_Employee_Simper_Records.InsertOnSubmit(newRecord1)
                newRecord1.UserID = Request.QueryString("UserID").ToString
                newRecord1.Valid_From = RadDatePicker_ValidFrom.SelectedDate
                newRecord1.Valid_Till = RadDatePicker_ValidTill.SelectedDate
                newRecord1.Project_ID = HttpContext.Current.Session("SelectedPID").ToString
                newRecord1.LastUpdateDate = DateTime.Now
                newRecord1.LastUpdateBy = HttpContext.Current.Session("UserID")
                dc.SubmitChanges()
                simperid = newRecord1.SIMPER_ID
     
                For Each row As GridDataItem In RadGrid1.Items
                    Dim lic_id As String = row("License_ID").Text
                    Dim lic_no As String = row("License_Number").Text
                    Dim lic_type As String = row("License_Type").Text
                    Dim lic_name As String = row("license_name").Text
                    Dim lic_issuer As String = row("License_Issuer").Text
                    Dim lic_v_from As DateTime = row("Valid_From").Text
                    Dim lic_v_till As DateTime = row("Valid_Till").Text
                    Dim lic_issue_date As DateTime = row("Issue_date").Text
     
                    dc.insertEmployeeSIMPER(simperid, Request.QueryString("UserID").ToString, HttpContext.Current.Session("SelectedPID").ToString, _
                                            lic_id, lic_no, lic_name, lic_type, lic_issuer, lic_v_from, lic_v_till, lic_issue_date,
                                            DateTime.Now, HttpContext.Current.Session("UserID").ToString)
                Next
     
                confirm = True
                dc.Dispose()
            Else
                confirm = False
            End If
     
            Return confirm
        End Function
     
        Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.DataBound
            'No License obtained
            If RadGrid1.Items.Count = 0 Then
                rtbMenu.FindItemByValue("Preview").Enabled = False
            Else
                rtbMenu.FindItemByValue("Preview").Enabled = True
            End If
        End Sub
     
        Protected Sub RadGrid2_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)
            If TypeOf e.Item Is GridDataItem Then
                Dim editLink As HyperLink = DirectCast(e.Item.FindControl("ViewLink"), HyperLink)
                editLink.Attributes("href") = "javascript:void(0);"
                editLink.Attributes("onclick") = [String].Format("return ShowSIMPER('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("SIMPER_ID"), e.Item.ItemIndex)
            End If
        End Sub
     
        Protected Sub RadGrid2_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)
     
            If e.CommandName = "RowClick" Then
     
                Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
                'Dim strId1 As String = item.GetDataKeyValue("UserID").ToString()
                'Response.Redirect("~/TrainingAdmin/SIMPER_details.aspx?UserID=" & strId1)
     
                'Dim editLink As HyperLink = DirectCast(e.Item.FindControl("ViewLink"), HyperLink)
                item.Attributes("href") = "javascript:void(0);"
                item.Attributes("onclick") = [String].Format("return ShowSIMPER('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("SIMPER_ID"), e.Item.ItemIndex)
     
            End If
     
        End Sub
    End Class


  2. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 01 Aug 2013 Link to this post

    I found that the error because the following code in masterpage.master

    <%= display_path%>

    i had comment the above code or change to <%# display_path%>, the error had disappear...
    but it cannot show the display_path in masterpage. How can i solve it ?

    masterpage code behind:

    Imports System
    Imports System.Collections.Generic
    Imports Telerik.Web.UI
    Imports System.Data
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
     
     
    Partial Class LRDB
        Inherits System.Web.UI.MasterPage
     
        Public display_path As String
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
            If Not IsPostBack Then
                Dim UID As String = HttpContext.Current.Session("UserID")
     
                'guard against calling the page without query string variable
                If Not IsNothing(UID) Then
                    lb_panel.Text = ""
     
                    'Get Staff Name
                    lb_StaffName.Text = GetNamebyUserID(UID)
     
                    'Generate Menu Bar By UserID, RoleTypeID
                    'Dim FID As String = GetFunctionIDByRoleTypeID(GetRoleTypeIDByUserID(UID))
                    'Generate Menu Bar By UserID, RoleTypeID, Project ID
                    Dim FID As String = GetFunctionIDByRoleTypeIDProjectID(GetRoleTypeIDByUserID(UID), HttpContext.Current.Session("SelectedPID"))
                    HttpContext.Current.Session("FID") = FID
     
           
     
                        If HttpContext.Current.Session("UserType") = "Employee" Then
                        'lb_break1.Visible = True
                        'lb_break2.Visible = True
                        'hl_MyRecord.Visible = True
                        'hl_MySchedule.Visible = True
                        'hl_MyRecord.NavigateUrl = "~/Employee/Employee_Training_Record.aspx"
                        'hl_MySchedule.NavigateUrl = "~/Employee/Employee_schedule.aspx"
                        cb_personal.Items.FindItemByValue("Learning_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Learning_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Profile").Visible = True
                        RadComboBox_Project.Visible = False
                        End If
                        If HttpContext.Current.Session("UserType") = "Trainer" Then
                        'lb_break1.Visible = True
                        'lb_break2.Visible = True
                        'hl_MyRecord.Visible = True
                        'hl_MySchedule.Visible = True
                        'hl_MyRecord.NavigateUrl = "~/Trainer/Trainer_Teaching_Record.aspx"
                        'hl_MySchedule.NavigateUrl = "~/Trainer/Trainer_schedule.aspx"
                        cb_personal.Items.FindItemByValue("Teaching_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Teaching_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Profile").Visible = True
                        RadComboBox_Project.Visible = False
                    End If
     
                    If HttpContext.Current.Session("UserType") = "Employee&Trainer" Then
                        cb_personal.Items.FindItemByValue("Teaching_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Teaching_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Learning_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Learning_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Profile").Visible = True
                        RadComboBox_Project.Visible = False
                    End If
     
                        cb_personal.Items.Insert(0, New Telerik.Web.UI.RadComboBoxItem(lb_StaffName.Text, "-1"))
                        'cb_personal.Items.Insert(1, New Telerik.Web.UI.RadComboBoxItem("My Profile", "1"))
                        'cb_personal.Items.Insert(2, New Telerik.Web.UI.RadComboBoxItem("My Learning - Record", "2"))
                        'cb_personal.Items.Insert(3, New Telerik.Web.UI.RadComboBoxItem("My Learning - Schedule", "3"))
                        'cb_personal.Items.Insert(4, New Telerik.Web.UI.RadComboBoxItem("My Teaching - Record", "4"))
                        'cb_personal.Items.Insert(5, New Telerik.Web.UI.RadComboBoxItem("My Teaching - Schedule", "5"))
                        'cb_personal.Items.Insert(6, New Telerik.Web.UI.RadComboBoxItem("Change Password", "6"))
     
                        'cb_personal.Items.Insert(7, New Telerik.Web.UI.RadComboBoxItem("Logout", "7"))
     
     
     
                        'get current function id via url
                        ' get http://10.188.1.101
                        'Request.Url.GetLeftPart(UriPartial.Authority)
     
                        'get http://10.188.1.101/Applications/LearningRecordDatabase
                        'Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath
     
                        'get whole URL without querystring
                        'Request.Url.GetLeftPart(UriPartial.Path)
     
                        Dim SelectFunctionID As Integer = 0
                        Dim currenturl1 As String = Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath
                        Dim currenturl2 As String = Request.Url.GetLeftPart(UriPartial.Path).Replace(currenturl1, "~")
     
                        Dim dc As New dcLRDBDataContext
                        Dim res = (From a In dc.db_LRDB_Functions Where a.Page Like currenturl2).ToList
     
                        Dim i As Integer = 0
     
                        If Not IsNothing(res) Then
                            If res.Count > 0 Then
                                HttpContext.Current.Session("SelectedFID") = res.Item(i).Function_ID
                            End If
                        End If
     
                        If Not IsNothing(HttpContext.Current.Session("SelectedFID")) Then
                            lb_panel.Text = GetMenuPathDisplayByFunctionID(HttpContext.Current.Session("SelectedFID")).ToString
                            display_path = GetMenuPathDisplayURLByFunctionID(HttpContext.Current.Session("SelectedFID")).ToString.Replace("~", _
                                                                                                                                          Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath)
                            If Not IsNothing(Request.QueryString("CourseID")) Then
                                display_path += "<b><Font face='Arial' Color='#485C7F' Size='5'> (" _
                                    & GetCourseNameByCourseID(Request.QueryString("CourseID").ToString) & ")</font></b>"
                            End If
                            If Not IsNothing(Request.QueryString("SessionID")) Then
                                display_path += "<b><Font face='Arial' Color='#485C7F' Size='5'> (" _
                                    & GetCourseNameByCourseID(GetCourseIDBySessionID(Request.QueryString("SessionID").ToString)) & ")</font></b>"
                            End If
                        Else
                            If Right(Request.Url.AbsolutePath, 9) = "Home.aspx" Then
                                lb_panel.Text = "Home"
                                display_path = "<b><Font face='Arial' Color='#485C7F' Size='5'>Home</font></b>"
                            Else
                                lb_panel.Text = ""
                                display_path = ""
                            End If
                        End If
     
     
                        'Check access right if user not click menubar. may type url or click sitemap...
                        HttpContext.Current.Session("accesslevel") = ""
     
                        'Get Access Level per each page after click the radmenu
                        Dim accesslevel As String = ""
                        'accesslevel = GetAccessLevelByRoleTypeIDFunctionID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedFID"))
                        accesslevel = GetAccessLevelByRoleTypeIDFunctionIDProjectID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), _
                                                                                    HttpContext.Current.Session("SelectedFID"), HttpContext.Current.Session("SelectedPID"))
                        HttpContext.Current.Session("accesslevel") = accesslevel
     
                        If IsNothing(HttpContext.Current.Session("accesslevel")) Or HttpContext.Current.Session("accesslevel") = "" Then
                            Response.Redirect("~/AccessDenied.aspx")
                        End If
     
                        dc.Dispose()
     
                    Else
                        Response.Redirect("~/Common/Login.aspx")
                    End If
                End If
     
        End Sub


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tarang
    Tarang avatar
    11 posts
    Member since:
    Jun 2013

    Posted 01 Aug 2013 Link to this post

    Will you please post your javascript code where you are refering "<%= display_path%>" ??

    You do not have to comment it out. If you are using RadTelerik Script Block, try wrapping it in <asp:Placeholder> control. It may work.
  5. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 01 Aug 2013 Link to this post

    the following are the code of the masterpage

    <%@ Master Language="VB" CodeFile="LRDB.master.vb" Inherits="LRDB" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head id="Head1" runat="server">
        <title></title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
        <style type="text/css">
     
            .style2
            {
                width: 100%;
            }
            .style3
            {
                width: 41px;
            }
            #frame_laio_tree
            {
                height: 502px;
            }
                    .style4
            {
                text-decoration: underline;
            }
            .style5
            {
                font-size: small;
                color: #000000;
            }
        </style>
        <link href="Style/StyleSheet.css" rel="stylesheet" type="text/css" />
    </head>
    <body>  
     
    <form id="form1" runat="server">
                <telerik:RadScriptManager runat="server" ID="RadScriptManager1"/>
                <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="false" />
                <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="true"   />
     
        <div style="font-family: Arial">
            <table class="style2">
                <tr>
                    <td class="style3">
                    <asp:Image ID="Logo" runat="server" ImageUrl="~/images/Logo.jpg" style="height:70px; width:auto;"/>
            </td>
                    <td style="background-color: #071440; font-family: Arial; font-size: x-large; color: #FFFFFF;">
            Learning Records Database</td>
                </tr>
            </table>
            <table style="width:100%; height:20px; border-collapse:collapse;">
    <tr style="background-color:#EF8201;" >
    <td style="width:70%;">Welcome 
    <asp:Label ID="lb_StaffName" style="color:White;" runat="server" Visible="false"></asp:Label>
      
    <telerik:RadComboBox AutoPostBack="true" Width="200" style="z-index: 7500" 
    AppendDataBoundItems="true" ID="cb_personal" runat="server" Skin="Sunset" EnableOverlay="true" HighlightTemplatedItems="true">
     
    <Items><telerik:RadComboBoxItem Text="My Profile" Value="Profile" Visible="false" /></Items>
    <Items><telerik:RadComboBoxItem Text="My Learning - Record" Value="Learning_Record" Visible="false" /></Items>
    <Items><telerik:RadComboBoxItem Text="My Learning - Schedule" Value="Learning_Schedule" Visible="false"  /></Items>
    <Items><telerik:RadComboBoxItem Text="My Teaching - Record" Value="Teaching_Record" Visible="false"  /></Items>
    <Items><telerik:RadComboBoxItem Text="My Teaching - Schedule" Value="Teaching_Schedule" Visible="false"  /></Items>
    <Items><telerik:RadComboBoxItem Text="Change Password" Value="Change_Password" /></Items>
    <Items><telerik:RadComboBoxItem Text="Logout" Value="Logout" /></Items>
     
    </telerik:RadComboBox>
      
     
    <%--<asp:HyperLink ID="hl_MyRecord" runat="server" CssClass="style5" Visible="false">My Record</asp:HyperLink>
        <span class="style5">
        <asp:Label ID="lb_break1" runat="server" Visible="false"> | </asp:Label>
    </span>
    <asp:HyperLink ID="hl_MySchedule" runat="server" CssClass="style5" Visible="false">My Schedule</asp:HyperLink>
        <span class="style5">
        <asp:Label ID="lb_break2" runat="server" Visible="false"> | </asp:Label>
    </span>
     
    <asp:HyperLink ID="hl_changepassword" runat="server"
            NavigateUrl="~/Common/Change_password.aspx" CssClass="style5">Change Password</asp:HyperLink>
        <span class="style5"> | 
    </span>
    <asp:HyperLink ID="hl_logout" runat="server"
            NavigateUrl="~/Common/logout.aspx" CssClass="style5">Logout</asp:HyperLink>
    --%>
    </td>
    <td>         
      <%--             <ul class="combo-list">
                   <li>--%>
             <telerik:RadComboBox runat="server" ID="RadComboBox_Project" EnableOverlay="true"
                          DataTextField="DisplayName"  DataValueField="ProjectID" Skin="Sunset"
                                  EnableLoadOnDemand="True" DataSourceID="ObjectDataSource2" style="z-index: 7500" 
                          OnSelectedIndexChanged="RadComboBox_Project_SelectedIndexChanged" AutoPostBack="True"
                                  HighlightTemplatedItems="true" Label="" Width="100%" NoWrap="True">
    <%--                              <HeaderTemplate>
                                       <ul>
                                            <li class="col1">Project Number | Project Name</li>
     
                                       </ul>
                                  </HeaderTemplate>
    --%>                              <ItemTemplate>
                                       <ul>
                                            <li class="col1"><%# Eval("ProjectNumber") + " | " + Eval("ProjectName")%></li>
                                            <%--<li class="col2"><%# Eval("ProjectName") %></li>--%>
                                       </ul>
                                  </ItemTemplate>
    <%--                              <Items>
                                                <telerik:RadComboBoxItem Text="Select a Project" Value="0" />
                                    </Items>--%>
                             </telerik:RadComboBox>
    <%--        </li> </ul>--%>
     
    </td></tr></table>
         </div>
           
         <div class="div_menu">
     
     
                 
     
         <table style="width:100%; ">
         <tr>
         <td style="width:100%;background-color:#E1DAC7; border-color:#CABAAB; border:0; border-style:solid;">
     
         <telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="True" EnableShadows="True"
            EnableTextHTMLEncoding="True" Skin="Sunset" DataSourceID="ObjectDataSource1" DataFieldID="Function_ID"
            DataFieldParentID="ParentID" DataValueField="Function_ID" DataTextField="Description"  style="z-index: 1000"
            OnDataBound="RadMenu1_DataBound" OnItemDataBound="RadMenu1_ItemDataBound" EnableOverlay="false"
            OnItemClick="RadMenu1_ItemClick" CausesValidation="false" >                         
            </telerik:RadMenu>    
            </td>        
         </tr>
         </table>  
     
     
             <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
                 SelectMethod="GetMenuArrayByFunctionID" TypeName="LRDB">
                 <SelectParameters>
                     <asp:SessionParameter DefaultValue="" Name="id" SessionField="FID"
                         Type="String" />                    
                 </SelectParameters>            
             </asp:ObjectDataSource>
     
             <asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
                 SelectMethod="GetProjectIDArrayByUserID" TypeName="LRDB">
                 <SelectParameters>
                     <asp:SessionParameter Name="id" SessionField="UserID" Type="Int32" />
                 </SelectParameters>
             </asp:ObjectDataSource>
     
            <hr  class= "menu_hr" />
    <%--            <asp:Panel ID="Panel1" runat="server" Height="50px" >
    --%>  
                  <asp:Label ID="lb_panel" runat="server" Font-Bold="true" ForeColor="#485C7F" Font-Names="Arial"
                Font-Size="18pt" Visible="false"></asp:Label>
      
              
              <%= display_path%>
                        <br /><br />
        <%--        <telerik:RadSiteMap ID="SiteMap1" runat="server"
                 DataFieldID="Function_ID" DataFieldParentID="ParentID"
                 DataNavigateUrlField="Page" DataSourceID="LDS_SiteMap2"
                 DataTextField="Description" DataValueField="Function_ID" Skin="WebBlue">
                 <LevelSettings>
                    <telerik:SiteMapLevelSetting Level="0" MaximumNodes="10">
                        <ListLayout RepeatDirection="Horizontal"></ListLayout>
                        <NodeTemplate>
                            <h3 class="Header">
                                <%# DataBinder.Eval(Container.DataItem, "Description")%>
                            </h3>
                        </NodeTemplate>
                    </telerik:SiteMapLevelSetting>
                </LevelSettings>
     
             </telerik:RadSiteMap>
             --%>
     
     
     
        <telerik:RadSiteMap runat="server" ID="SiteMap1" DataFieldID="Function_ID" DataFieldParentID="ParentID"
                 DataNavigateUrlField="Page" DataSourceID="LDS_SiteMap2" Visible="false"
                 DataTextField="Description" DataValueField="Function_ID" Skin="WebBlue">
            <LevelSettings>
                <telerik:SiteMapLevelSetting Level="0">
                    <ListLayout RepeatColumns="3" RepeatDirection="Horizontal" AlignRows="true"></ListLayout>
                </telerik:SiteMapLevelSetting>
            </LevelSettings>
            <DataBindings>
                <telerik:RadSiteMapNodeBinding NavigateUrl="#"></telerik:RadSiteMapNodeBinding>
            </DataBindings>
        </telerik:RadSiteMap>
     
             <asp:ObjectDataSource ID="ODS_SiteMap" runat="server"
                 SelectMethod="GetMenuArrayByFunctionID" TypeName="LRDB">
                 <SelectParameters>
                     <asp:SessionParameter DefaultValue="0" Name="id" SessionField="SelectedFID"
                         Type="String" />
                 </SelectParameters>
             </asp:ObjectDataSource>
     
             <asp:LinqDataSource ID="LDS_SiteMap" runat="server"
                 ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                 TableName="db_LRDB_Functions" >
             </asp:LinqDataSource>
     
             <asp:LinqDataSource ID="LDS_SiteMap2" runat="server"
                 ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                 TableName="db_LRDB_Functions" Where="Function_ID == @Function_ID">
                 <WhereParameters>
                     <asp:SessionParameter DefaultValue="0" Name="Function_ID"
                         SessionField="SelectedFID" Type="Int32" />
                 </WhereParameters>
             </asp:LinqDataSource>
     
    <%--    </asp:Panel>
    --%>
             <div id="content_function" class="content_function">              
                <div id="content" class="content">
     
    <%-- Left hand side LAIO tree list --%>
     
    <%--<table style="width:100%; height: 622px;">
    <tr>
    <td valign="top" style="background-color:#DBDFE4; width:200px;">
    <iframe id="frame_laio_tree" src="~/LAIO_tree.aspx" scrolling="no" frameborder="0" width="190px">
     </iframe>
    </td>
    <td valign="top" style="width:auto;">--%>
         
    <%-- Left hand side LAIO tree list --%>
     
    <asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server" ></asp:ContentPlaceHolder>
     
    <%-- Left hand side LAIO tree list --%>
    <%--</td>
     
    </tr>
    </table>--%>
    <%-- Left hand side LAIO tree list --%>
     
        </div>
                        
                   <br />
                                   <span class="style4"><strong></strong>
    <br /><br /><br />
                       </span>
         </div>
     </div>
       
     
          </form>
    </body>
    </html>

    Code Behind:

    Imports System
    Imports System.Collections.Generic
    Imports Telerik.Web.UI
    Imports System.Data
    Imports System.Web
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
     
     
    Partial Class LRDB
        Inherits System.Web.UI.MasterPage
     
        Public display_path As String
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
            If Not IsPostBack Then
                Dim UID As String = HttpContext.Current.Session("UserID")
     
                'guard against calling the page without query string variable
                If Not IsNothing(UID) Then
                    lb_panel.Text = ""
     
                    'Get Staff Name
                    lb_StaffName.Text = GetNamebyUserID(UID)
     
                    'Generate Menu Bar By UserID, RoleTypeID
                    'Dim FID As String = GetFunctionIDByRoleTypeID(GetRoleTypeIDByUserID(UID))
                    'Generate Menu Bar By UserID, RoleTypeID, Project ID
                    Dim FID As String = GetFunctionIDByRoleTypeIDProjectID(GetRoleTypeIDByUserID(UID), HttpContext.Current.Session("SelectedPID"))
                    HttpContext.Current.Session("FID") = FID
     
           
     
                        If HttpContext.Current.Session("UserType") = "Employee" Then
                        'lb_break1.Visible = True
                        'lb_break2.Visible = True
                        'hl_MyRecord.Visible = True
                        'hl_MySchedule.Visible = True
                        'hl_MyRecord.NavigateUrl = "~/Employee/Employee_Training_Record.aspx"
                        'hl_MySchedule.NavigateUrl = "~/Employee/Employee_schedule.aspx"
                        cb_personal.Items.FindItemByValue("Learning_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Learning_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Profile").Visible = True
                        RadComboBox_Project.Visible = False
                        End If
                        If HttpContext.Current.Session("UserType") = "Trainer" Then
                        'lb_break1.Visible = True
                        'lb_break2.Visible = True
                        'hl_MyRecord.Visible = True
                        'hl_MySchedule.Visible = True
                        'hl_MyRecord.NavigateUrl = "~/Trainer/Trainer_Teaching_Record.aspx"
                        'hl_MySchedule.NavigateUrl = "~/Trainer/Trainer_schedule.aspx"
                        cb_personal.Items.FindItemByValue("Teaching_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Teaching_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Profile").Visible = True
                        RadComboBox_Project.Visible = False
                    End If
     
                    If HttpContext.Current.Session("UserType") = "Employee&Trainer" Then
                        cb_personal.Items.FindItemByValue("Teaching_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Teaching_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Learning_Record").Visible = True
                        cb_personal.Items.FindItemByValue("Learning_Schedule").Visible = True
                        cb_personal.Items.FindItemByValue("Profile").Visible = True
                        RadComboBox_Project.Visible = False
                    End If
     
                        cb_personal.Items.Insert(0, New Telerik.Web.UI.RadComboBoxItem(lb_StaffName.Text, "-1"))
                        'cb_personal.Items.Insert(1, New Telerik.Web.UI.RadComboBoxItem("My Profile", "1"))
                        'cb_personal.Items.Insert(2, New Telerik.Web.UI.RadComboBoxItem("My Learning - Record", "2"))
                        'cb_personal.Items.Insert(3, New Telerik.Web.UI.RadComboBoxItem("My Learning - Schedule", "3"))
                        'cb_personal.Items.Insert(4, New Telerik.Web.UI.RadComboBoxItem("My Teaching - Record", "4"))
                        'cb_personal.Items.Insert(5, New Telerik.Web.UI.RadComboBoxItem("My Teaching - Schedule", "5"))
                        'cb_personal.Items.Insert(6, New Telerik.Web.UI.RadComboBoxItem("Change Password", "6"))
     
                        'cb_personal.Items.Insert(7, New Telerik.Web.UI.RadComboBoxItem("Logout", "7"))
     
     
     
                        'get current function id via url
                        ' get http://10.188.1.101
                        'Request.Url.GetLeftPart(UriPartial.Authority)
     
                        'get http://10.188.1.101/Applications/LearningRecordDatabase
                        'Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath
     
                        'get whole URL without querystring
                        'Request.Url.GetLeftPart(UriPartial.Path)
     
                        Dim SelectFunctionID As Integer = 0
                        Dim currenturl1 As String = Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath
                        Dim currenturl2 As String = Request.Url.GetLeftPart(UriPartial.Path).Replace(currenturl1, "~")
     
                        Dim dc As New dcLRDBDataContext
                        Dim res = (From a In dc.db_LRDB_Functions Where a.Page Like currenturl2).ToList
     
                        Dim i As Integer = 0
     
                        If Not IsNothing(res) Then
                            If res.Count > 0 Then
                                HttpContext.Current.Session("SelectedFID") = res.Item(i).Function_ID
                            End If
                        End If
     
                        If Not IsNothing(HttpContext.Current.Session("SelectedFID")) Then
                            lb_panel.Text = GetMenuPathDisplayByFunctionID(HttpContext.Current.Session("SelectedFID")).ToString
                            display_path = GetMenuPathDisplayURLByFunctionID(HttpContext.Current.Session("SelectedFID")).ToString.Replace("~", _
                                                                                                                                          Request.Url.GetLeftPart(UriPartial.Authority) & Request.ApplicationPath)
                            If Not IsNothing(Request.QueryString("CourseID")) Then
                                display_path += "<b><Font face='Arial' Color='#485C7F' Size='5'> (" _
                                    & GetCourseNameByCourseID(Request.QueryString("CourseID").ToString) & ")</font></b>"
                            End If
                            If Not IsNothing(Request.QueryString("SessionID")) Then
                                display_path += "<b><Font face='Arial' Color='#485C7F' Size='5'> (" _
                                    & GetCourseNameByCourseID(GetCourseIDBySessionID(Request.QueryString("SessionID").ToString)) & ")</font></b>"
                            End If
                        Else
                            If Right(Request.Url.AbsolutePath, 9) = "Home.aspx" Then
                                lb_panel.Text = "Home"
                                display_path = "<b><Font face='Arial' Color='#485C7F' Size='5'>Home</font></b>"
                            Else
                                lb_panel.Text = ""
                                display_path = ""
                            End If
                        End If
     
     
                        'Check access right if user not click menubar. may type url or click sitemap...
                        HttpContext.Current.Session("accesslevel") = ""
     
                        'Get Access Level per each page after click the radmenu
                        Dim accesslevel As String = ""
                        'accesslevel = GetAccessLevelByRoleTypeIDFunctionID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedFID"))
                        accesslevel = GetAccessLevelByRoleTypeIDFunctionIDProjectID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), _
                                                                                    HttpContext.Current.Session("SelectedFID"), HttpContext.Current.Session("SelectedPID"))
                        HttpContext.Current.Session("accesslevel") = accesslevel
     
                        If IsNothing(HttpContext.Current.Session("accesslevel")) Or HttpContext.Current.Session("accesslevel") = "" Then
                            Response.Redirect("~/AccessDenied.aspx")
                        End If
     
                        dc.Dispose()
     
                    Else
                        Response.Redirect("~/Common/Login.aspx")
                    End If
                End If
     
        End Sub
     
        Protected Sub RadMenu1_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs) Handles RadMenu1.ItemClick
            'Response.Redirect("~/LAIO_tree.aspx")
            HttpContext.Current.Session("accesslevel") = ""
     
            Dim SelectFunctionID As Integer = 0
            SelectFunctionID = e.Item.Value
            HttpContext.Current.Session("SelectedFID") = SelectFunctionID
     
            'Get Access Level per each page after click the radmenu
            Dim accesslevel As String = ""
            'accesslevel = GetAccessLevelByRoleTypeIDFunctionID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedFID"))
            accesslevel = GetAccessLevelByRoleTypeIDFunctionIDProjectID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedFID"), HttpContext.Current.Session("SelectedPID"))
            HttpContext.Current.Session("accesslevel") = accesslevel
     
            If IsNothing(HttpContext.Current.Session("accesslevel")) Or HttpContext.Current.Session("accesslevel") = "" Then
                Response.Redirect("~/AccessDenied.aspx")
            End If
     
            Dim dc As New dcLRDBDataContext
            Dim result = (From d In dc.db_LRDB_Functions Where d.Function_ID = SelectFunctionID Select d).FirstOrDefault
            If Not IsNothing(result) Then
                If result.Page <> "" Then
                    Response.Redirect(result.Page)
                End If
            End If
     
        End Sub
     
        Protected Sub RadMenu1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
     
            Me.InsertSeparator(0, Me.RadMenu1)
        End Sub
     
        Public Sub RadMenu1_ItemDataBound(ByVal sender As Object, ByVal e As RadMenuEventArgs)
            If e.Item.Level = 0 Then
     
                'set radmenu items width
                Me.RadMenu1.Items(e.Item.Index).Width = Unit.Pixel(100)
     
                Me.InsertSeparator(e.Item.Index + 1, Me.RadMenu1)
            End If
        End Sub
     
        Private Sub InsertSeparator(ByVal index As Integer, ByVal menu As RadMenu)
            Dim separator As New RadMenuItem()
            separator.IsSeparator = True
            separator.Text = "|"
            menu.Items.Insert(index, separator)
        End Sub
     
        'Protected Sub RadDropDownList_Project_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadDropDownList_Project.DataBinding
        '    If Not IsNothing(HttpContext.Current.Session("SelectedPID")) Then
        '        RadDropDownList_Project.SelectedValue = HttpContext.Current.Session("SelectedPID")
        '    Else
        '        RadDropDownList_Project.SelectedValue = RadDropDownList_Project.DefaultMessage
        '    End If
        'End Sub
     
        'Protected Sub RadDropDownList_Project_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.DropDownListEventArgs) Handles RadDropDownList_Project.SelectedIndexChanged
        '    HttpContext.Current.Session("SelectedPID") = RadDropDownList_Project.SelectedValue
        'End Sub
     
        Protected Sub RadComboBox_Project_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadComboBox_Project.DataBinding
     
            If Not IsNothing(HttpContext.Current.Session("SelectedPID")) Then
                RadComboBox_Project.SelectedValue = HttpContext.Current.Session("SelectedPID")
            Else
                'HttpContext.Current.Session("SelectedPID") = "0"
            End If
        End Sub
     
        Protected Sub RadComboBox_Project_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadComboBox_Project.DataBound
            Dim combo As RadComboBox = DirectCast(sender, RadComboBox)
            If combo.Items.Count > 1 Then
                combo.Items.Insert(0, New RadComboBoxItem("Select a Project", String.Empty))
     
                'Dim item As RadComboBoxItem = New RadComboBoxItem
                'item.Text = "Select a Project"
                'RadComboBox_Project.Items.Insert(0, item)
                'item.DataBind()
     
            Else
                'Automatically set to selected project if only one responsible project
     
                RadComboBox_Project.SelectedValue = GetProjectListByUserID(HttpContext.Current.Session("UserID")).ToString
                HttpContext.Current.Session("SelectedPID") = RadComboBox_Project.SelectedValue
     
                'Bind menubar
                Dim FID As String = GetFunctionIDByRoleTypeIDProjectID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedPID"))
                HttpContext.Current.Session("FID") = FID
     
                RadMenu1.DataBind()
     
            End If
     
        End Sub
        Protected Sub cb_personal_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles cb_personal.SelectedIndexChanged
            If cb_personal.SelectedValue = "Profile" Then
                Response.Redirect("~/Common/MyProfile.aspx")
            ElseIf cb_personal.SelectedValue = "Learning_Record" Then
                Response.Redirect("~/Employee/Employee_Training_Record.aspx")
            ElseIf cb_personal.SelectedValue = "Learning_Schedule" Then
                Response.Redirect("~/Employee/Employee_schedule.aspx")
            ElseIf cb_personal.SelectedValue = "Teaching_Record" Then
                Response.Redirect("~/Trainer/Trainer_Teaching_Record.aspx")
            ElseIf cb_personal.SelectedValue = "Teaching_Schedule" Then
                Response.Redirect("~/Trainer/Trainer_schedule.aspx")
            ElseIf cb_personal.SelectedValue = "Change_Password" Then
                Response.Redirect("~/Common/Change_password.aspx")
            ElseIf cb_personal.SelectedValue = "Logout" Then
                Response.Redirect("~/Common/logout.aspx")
            End If
        End Sub
        Protected Sub RadComboBox_Project_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles RadComboBox_Project.SelectedIndexChanged
     
            If RadComboBox_Project.SelectedValue = "" Or RadComboBox_Project.SelectedValue = "0" Then
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('Please select a Project.');", True)
                HttpContext.Current.Session("SelectedPID") = "0"
            End If
     
            HttpContext.Current.Session("SelectedPID") = RadComboBox_Project.SelectedValue
     
     
            '================================
            'Option 1
            '
            'Redirect to Home.aspx when change project
            '================================
            'Session.Remove("SelectedFID")
            'Response.Redirect("~/Common/Home.aspx")
            '================================
            'Option 1
            '
            'Redirect to Home.aspx
            '================================
     
     
     
     
            '================================
            'Option 2
            '
            'Refresh and remain at the existing page
            '================================
            'Refresh Menu Bar By UserID, RoleTypeID, Project ID
            Dim FID As String = GetFunctionIDByRoleTypeIDProjectID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedPID"))
            HttpContext.Current.Session("FID") = FID
     
            RadMenu1.DataBind()
     
            'Get Access Level per each page after change the project
            Dim accesslevel As String = ""
            'accesslevel = GetAccessLevelByRoleTypeIDFunctionID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedFID"))
            accesslevel = GetAccessLevelByRoleTypeIDFunctionIDProjectID(GetRoleTypeIDByUserID(HttpContext.Current.Session("UserID")), HttpContext.Current.Session("SelectedFID"), HttpContext.Current.Session("SelectedPID"))
            HttpContext.Current.Session("accesslevel") = accesslevel
     
            If IsNothing(HttpContext.Current.Session("accesslevel")) Or HttpContext.Current.Session("accesslevel") = "" Then
                If Not IsNothing(HttpContext.Current.Session("SelectedFID")) Then
                    Response.Redirect("~/AccessDenied.aspx")
                End If
            Else
                Dim dc As New dcLRDBDataContext
                Dim result = (From cs In dc.db_LRDB_Functions Where cs.Function_ID = HttpContext.Current.Session("SelectedFID").ToString).FirstOrDefault
                If Not IsNothing(result.Page) Then
                    If result.Page <> "" Then
                        Response.Redirect(result.Page)
                    End If
                End If
                'reload page
            End If
            '================================
            'Option 2
            '
            'Refresh and remain at the existing page
            '================================
        End Sub
     
     
        Protected Sub SiteMap1_NodeDataBound(ByVal sender As Object, ByVal e As RadSiteMapNodeEventArgs) Handles SiteMap1.NodeDataBound
            ' Show only first and second nodes.
            ' The third level will not be displayed, but will be included in the total count.
            If e.Node.Level > 10 Then
                e.Node.Visible = False
            End If
            e.Node.Text = Server.HtmlEncode(e.Node.Text)
     
        End Sub
     
     
        Protected Sub SiteMap1_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles SiteMap1.DataBound
            For Each node As RadSiteMapNode In SiteMap1.GetAllNodes()
                Dim childNodes As Integer = CountChildNodes(node)
                If childNodes > 0 Then
                    node.Text = String.Format("{0}  <b>({1})</b>", node.Text, childNodes)
                End If
            Next
        End Sub
     
     
        Private Function CountChildNodes(ByVal node As RadSiteMapNode) As Integer
            Dim count As Integer = node.Nodes.Count
            For Each childNode As RadSiteMapNode In node.Nodes
                count += CountChildNodes(childNode)
            Next
            Return count
        End Function
     
    End Class

    I had tried to enable the display_path code and using asp:placeholder instead of scriptblock, but it doesn't work
    the display_path content cannot display....


  6. Tarang
    Tarang avatar
    11 posts
    Member since:
    Jun 2013

    Posted 02 Aug 2013 Link to this post

    Well actually this works for me. For this demo i've removed all unnecessary code.

    This is Master Page :
    <%@ Master Language="VB" CodeFile="LRDB.Master.vb" Inherits="LRDB" %>
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <title>LEIGHTON Learning Records Database (LRDB)</title>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
        <label>
            <%= display_path %>
        </label>
        </form>
    </body>
    </html>


    This is code behind for it:
    Partial Class LRDB
        Inherits System.Web.UI.MasterPage
     
        Public display_path As String
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     
            If Not IsPostBack Then
                display_path = "This is Display Path which is being shown and referred in master page."
            End If
     
        End Sub
     
     
     
    End Class

    Also i've attached output for it. Check the output.png


  7. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 04 Aug 2013 Link to this post

    thanks for your effort.

    i had amend the dispay_path sentence in masterpage to following:

        <asp:PlaceHolder ID="PlaceHolder1" runat="server">
             <label>
              <%= display_path%>         
        </label>
    </asp:PlaceHolder>

    I can display the display and let user to click the "preview" button to pop up a radwindow.

    but i found that the display_path will be disappear when i click the "preview" button.
    If i reload the browser, the display_path will display again.... How can i fix it /avoid it disappear ?
    Thanks.






  8. Tarang
    Tarang avatar
    11 posts
    Member since:
    Jun 2013

    Posted 05 Aug 2013 Link to this post

    Will you please replace your RadscriptBlock with RadCodeBlock and try again?
  9. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Aug 2013 Link to this post

    Hello Joe,

    Note that you should warp all the server code block in the markup with RadCodeBlock or RadScriptBlock controls. Give this a try and verify if this helps.

    Regards,
    Maria Ilieva
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017