Unable to use User Control inside Portlet control - This type of page is not served

  1. #1

    Unable to use User Control inside Portlet control - This type of page is not served

    I want to use user control inside the portlet but getting an error

    "This type of page is not served.".

    If I give URL to the aspx page it works fine.

    My question is is there is any way to call user control inside Porlet.

    <ext:Portlet ID="Portlet4" Title="Dundas Chart" runat="server" Height="450">
           <Loader ID="Loader2" runat="server" Url="~/TestUserControl.ascx" Mode="Frame" />
     </ext:Portlet>
    Thanks for your help.
    Last edited by geoffrey.mcgill; Apr 06, 2012 at 6:14 PM. Reason: please use [CODE] tags
  2. #2
    Hi,

    Loader doesn't support loading user controls.

    You can place a user control within Content.

    Example
    <ext:Portlet runat="server">
        <Content>
            <uc:TestUserControl runat="server" />
        </Content>
    </ext:Portlet>
    Or, if you have only Ext.NET components (top level) within a user control you can use UserControlLoader. It will extract Ext.NET components from a user control and place them into Control Items.

    Example
    <ext:Portlet runat="server">
        <Items>
            <ext:UserControlLoader runat="server" Path="~/TestUserControl.ascx" />
        </Items>
    </ext:Portlet>
  3. #3

    RE

    Hi Daniil,

    Thanks for the reply.

    Option 1 works. But I want my user control to load in the deferred load mode. That was the reason I have placed it inside the Loader yag.

    Option 2 is giving me following error. My user control only has standard Microsoft Label Control

    Control with type 'System.Web.UI.WebControls.Label' cannot be handled by layout





    Quote Originally Posted by Daniil View Post
    Hi,

    Loader doesn't support loading user controls.

    You can place a user control within Content.

    Example
    <ext:Portlet runat="server">
        <Content>
            <uc:TestUserControl runat="server" />
        </Content>
    </ext:Portlet>
    Or, if you have only Ext.NET components (top level) within a user control you can use UserControlLoader. It will extract Ext.NET components from a user control and place them into Control Items.

    Example
    <ext:Portlet runat="server">
        <Items>
            <ext:UserControlLoader runat="server" Path="~/TestUserControl.ascx" />
        </Items>
    </ext:Portlet>
  4. #4
    Apologize for the delay.

    For deferred loading of a user control we can suggest the following solution.

    Example Page
    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <script runat="server">
        [DirectMethod]
        public static void LoadUserControl(string containerId)
        {
            X.Js.AddScript(UserControlRenderer.ToScript(new UserControlRendrerConfig
            {
                UserControlPath = "TestUC.ascx",
                Mode = RenderMode.AddTo,
                SingleControl = true,
                Element = containerId
            }));
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />   
    
        <ext:Panel
            runat="server"        
            Height="200"
            Width="500"
            Layout="FitLayout">
            <Listeners>
                <AfterRender Handler="#{DirectMethods}.LoadUserControl(this.id);" />
            </Listeners>
        </ext:Panel>
    
    </body>
    </html>
    Example User Control
    <%@ Control Language="C#" ClassName="TestUC" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:Container runat="server">
        <Content>
            <asp:Label runat="server" Text="I am ASP.NET Label" /> 
        </Content>
    </ext:Container>
  5. #5
    Hi Danii,

    Tanks ,
    this side works now.
    But the other side, I have the grid with the portlet entries and I want set the portlet to hidden = false..
    In my sample application it doesn't work.
    And the next problem is the expand control and unexpand control button.
    If I expand the control on the top the second control will be expanded.

    Modiefied Code.

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Dashboard.aspx.vb" Inherits="TestApplikation.Dashboard" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="Ext.Net.Utilities" %>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    <%@ Register TagPrefix="ucPermitGrid" TagName="PermitGrid" Src="~/TestUserControl.ascx" %>
    <script runat="server">
     
     Public Class PortletItem
      Public PortletDashboard As String
      Public PortletId As String
      Public PortletName As String
      Public PortletIcon As String
      Public PortletIsHidden As Boolean
     End Class
     
     Private table As DataTable
        Private reader As Ext.Net.Model = Nothing
     'Private portletItems As List(Of PortletItem)
     Private portlets As List(Of PortletItem) = Nothing
     
     Public Sub RefreshTree(portlets As List(Of PortletItem))
      Me.DashboardGrid.Store.Clear()
      Me.DashboardGrid.Store.Add(CreateStore(GridReader))
      Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
      table = Nothing
      st.DataSource = FillTable(DashboardTable, portlets)
      st.DataBind()
     End Sub
     
     Private ReadOnly Property PortletList As List(Of PortletItem)
      Get
       If portlets Is Nothing Then
        portlets = New List(Of PortletItem)
        Dim pi As New PortletItem
        pi.PortletDashboard = "Dashboard"
        pi.PortletId = "ptPermit"
        pi.PortletIcon = "Lock"
        pi.PortletName = "permit"
                    pi.PortletIsHidden = False
        portlets.Add(pi)
        pi = New PortletItem
        pi.PortletDashboard = "Dashboard"
        pi.PortletId = "ptEvent"
        pi.PortletIcon = "LightningAdd"
        pi.PortletName = "Eevent"
                    pi.PortletIsHidden = false
        portlets.Add(pi)
       End If
       Return portlets
      End Get
     End Property
     
        Public Function CreateStore(Optional reader As Ext.Net.Model = Nothing) As Ext.Net.Store
            Dim st As New Ext.Net.Store
            st.ID = "DashboardStore"
            If Not IsNothing(reader) Then
                st.Model.Add(reader)
            End If
            st.GroupField = "PortletDashboard"
            Return st
        End Function
     
        Public ReadOnly Property GridReader As Ext.Net.Model
            Get
                If reader Is Nothing Then
                    reader = New Ext.Net.Model
                    reader.Fields.Add(New Ext.Net.ModelField("PortletDashboard"))
                    reader.Fields.Add(New Ext.Net.ModelField("PortletId"))
                    reader.Fields.Add(New Ext.Net.ModelField("PortletName"))
                    reader.Fields.Add(New Ext.Net.ModelField("PortleIcon"))
                End If
                Return reader
            End Get
        End Property
     
     Private ReadOnly Property DashboardTable As DataTable
      Get
       If table Is Nothing Then
        table = New DataTable
        table.Columns.Add("PortletDashboard", GetType(System.String))
        table.Columns.Add("PortletId", GetType(System.String))
        table.Columns.Add("PortletName", GetType(System.String))
        table.Columns.Add("PortleIcon", GetType(System.String))
       End If
       Return table
      End Get
     End Property
     
     Private Function FillTable(table As DataTable, list As List(Of PortletItem)) As DataTable
      For Each pi In list
       If pi.PortletIsHidden = True Then
        Dim datarow As DataRow = table.NewRow()
        datarow.SetField(Of String)("PortletDashboard", pi.PortletDashboard)
        datarow.SetField(Of String)("PortletId", pi.PortletId)
        datarow.SetField(Of String)("PortletName", pi.PortletName)
        datarow.SetField(Of String)("PortleIcon", pi.PortletIcon)
        table.Rows.Add(datarow)
       End If
      Next
      Return table
     End Function
     
     <DirectMethod()>
     Public Sub SelectPortlet(ByVal sender As Object, ByVal e As DirectEventArgs)
      Dim portletId = e.ExtraParams("PortletId")
      Dim res = (From a In portlets Where a.PortletId = portletId).Single
      portlets.Remove(res)
      res.PortletIsHidden = False
      portlets.Add(res)
      Me.DashboardGrid.Store.Clear()
      Me.DashboardGrid.Store.Add(CreateStore(GridReader))
      Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
      table = Nothing
      st.DataSource = FillTable(DashboardTable, portlets)
      st.DataBind()
            ChangePortlet_Event(portlets)
     End Sub
     
     Private Sub ChangePortlet_Event(portl As List(Of PortletItem))
         
            Dim s
      Dim pl As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
            portlets = portl
            For Each p In pl
                Dim pi As PortletItem = (From a In portl Where a.PortletId = p.ID Select a).SingleOrDefault
                If pi.PortletIsHidden <> p.Hidden Then
                    p.Hidden = pi.PortletIsHidden
                End If
                ' p.Hidden = pi.PortletIsHidden
                s += p.ID + "   " + p.Hidden.ToString() + "   "
            Next
            
            Ext.Net.X.Msg.Alert("Status", s).Show()
     End Sub
     
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            
            If Not ExtNet.IsAjaxRequest And Not IsPostBack Then
                portlets = PortletList
                Session("Portlets") = portlets
            Else
                portlets = CType(Session("Portlets"), Global.System.Collections.Generic.List(Of PortletItem))
            End If
            Me.DashboardGrid.Store.Add(CreateStore(GridReader))
            Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
            st.DataSource = FillTable(DashboardTable, portlets)
            st.DataBind()
            Dim portletControls As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
            For Each control In portletControls
    
                
                If Not ExtNet.IsAjaxRequest Then
                    control.CloseAction = CloseAction.Hide
                    control.DirectEvents.Hide.EventMask.ShowMask = True
                    control.DirectEvents.Hide.EventMask.Msg = "Saving..."
                    control.DirectEvents.Hide.EventMask.MinDelay = 500
                    control.DirectEvents.Hide.ExtraParams.Add(New Ext.Net.Parameter("ID", control.ClientID))
                    If control.ID.Contains("Permit") Then
                        Dim pi As PortletItem = (From a In portlets Where a.PortletId = control.ID Select a).SingleOrDefault
                        control.Hidden = pi.PortletIsHidden
                        AddHandler control.DirectEvents.Hide.Event, AddressOf Portlet_Hide_Event
                    ElseIf control.ID.Contains("Event") Then
                        Dim pi As PortletItem = (From a In portlets Where a.PortletId = control.ID Select a).SingleOrDefault
                        control.Hidden = pi.PortletIsHidden
                        AddHandler control.DirectEvents.Hide.Event, AddressOf Portlet_Hide_Event
                    End If
                Else
                    AddHandler control.DirectEvents.Hide.Event, AddressOf Portlet_Hide_Event
                End If
      
            Next
        End Sub
    
     Protected Sub Portlet_Hide_Event(sender As Object, e As DirectEventArgs)
      Ext.Net.X.Msg.Alert("Status", e.ExtraParams("ID") + " Hidden").Show()
     
            Dim id As String = e.ExtraParams("ID")
            Dim ids() As String = id.Split(CChar("."))
      Dim pi As PortletItem = (From a In portlets Where a.PortletId = ids(1) Select a).SingleOrDefault
      pi.PortletIsHidden = True
      RefreshTree(portlets)
    
     End Sub
    
     
     
     </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
     <form id="Form1" runat="server">
     <ext:ResourceManager ID="ResourceManager1" runat="server" />
     <ext:Viewport ID="Viewport1" runat="server" layout="BorderLayout">
      <Items>
                <ext:Panel ID="Tab1" runat="server" Title="Internet" Icon="Vcard" BodyStyle="background-color: transparent;"
                    Region="Center" Width="300" >
                    <Items>
                        <ext:Portal ID="Portal1" runat="server" Border="false" BodyStyle="background-color: transparent;"
                            Layout="Column">
                            <Items>
                                <ext:PortalColumn ID="PortalColumn1" runat="server" StyleSpec="padding:10px 0 10px 10px"
                                    ColumnWidth=".5" Layout="Anchor">
                                    <Items>
                                        
                                    </Items>
                                </ext:PortalColumn>
                                <ext:PortalColumn ID="PortalColumn2" runat="server" StyleSpec="padding:10px 0 10px 10px"
                                    ColumnWidth=".5" Layout="Anchor">
                                    <Items>
                                        <ext:Portlet ID="ptPermit" runat="server" Title="Permit" >
                                            <Content>
                                                  <ucPermitGrid:PermitGrid ID="PermitGrid2" runat="server" />
                                            </Content>
                                        </ext:Portlet>
                                        <ext:Portlet ID="ptEvent" Title="Event" runat="server" >
                                            <Content>
                                                  <ucPermitGrid:PermitGrid ID="PermitGrid1" runat="server" />
                                            </Content>
                                        </ext:Portlet>
                                    </Items>
                                </ext:PortalColumn>
                            </Items>
                        </ext:Portal>
                    </Items>
                </ext:Panel>
     
                <ext:Panel runat="server" Title="Settings" Width="180" ID="Panel1" Layout="FitLayout" Region="West" MinWidth="175" MaxWidth="1740" Html="asdfg" BodyStyle="background-color: red;">
                    <Items>
                        <ext:GridPanel ID="DashboardGrid" runat="server" 
                            Border="false"  HideHeaders="True">
                            <ColumnModel>
                                <Columns>
                                    <ext:Column runat="server" ID="colDashboard" DataIndex="PortletDashboard" Width="0"
                                        Hidden="true" Groupable="False" Sortable="False" MenuDisabled="False" />
                                    <ext:Column runat="server" ID="colId" DataIndex="PortletId" Width="20" Hidden="true"
                                        Groupable="False" Sortable="False" MenuDisabled="False" />
                                    <ext:Column runat="server" ID="colPortletName" DataIndex="PortletName" Width="200" 
                                        Hidden="false" Groupable="False" Sortable="False" MenuDisabled="False" />
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Simple">
                                    <DirectEvents>
                                        <Select OnEvent="SelectPortlet">
                                            <EventMask ShowMask="true" />
                                            <ExtraParams>
                                                <ext:Parameter Name="PortletId" Value="record.data.PortletId" Mode="Raw" />
                                            </ExtraParams>
                                        </Select>
                                    </DirectEvents>
                                </ext:RowSelectionModel>
                            </SelectionModel>
                        </ext:GridPanel>
                    </Items>
                </ext:Panel>
      </Items>
     </ext:Viewport>
     </form>
    </body>
    </html>

    and the user control

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="TestUserControl.ascx.vb" Inherits="TestApplikation.TestUserControl" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
     <ext:Container ID="Container1" runat="server">
        <Content>
            <asp:Label ID="Label1" runat="server" Text="I am ASP.NET Label" />
        </Content>
    </ext:Container>
    Hope you can help me.

    Kind regardes
    Elke
  6. #6
    Hi Peter,

    I am a bit confused. Is your post related to this thread?
    http://forums.ext.net/showthread.php?23211
  7. #7
    Quote Originally Posted by Daniil View Post
    Hi Peter,

    I am a bit confused. Is your post related to this thread?
    http://forums.ext.net/showthread.php?23211


    Hi Daniil,

    i'm Elke und not Peter.

    You are right, this was a mistake from me.
    Should I post my question on the other tread or can you give me an answer anyway.
    Kind regards

    Elke
  8. #8
    Quote Originally Posted by sisa View Post
    i'm Elke und not Peter.
    I am sorry. Just sometimes I see "Peter" in your post. I thought it is the first name and "Elke" is the last name.

    Sorry again.

    Quote Originally Posted by sisa View Post
    You are right, this was a mistake from me.
    Should I post my question on the other tread or can you give me an answer anyway.
    Yes, please continue the thread that you started.
    http://forums.ext.net/showthread.php?23211

Similar Threads

  1. Replies: 5
    Last Post: Apr 28, 2012, 5:21 AM
  2. Replies: 2
    Last Post: Feb 06, 2012, 9:06 AM
  3. Replies: 7
    Last Post: Apr 14, 2011, 10:52 PM
  4. Replies: 1
    Last Post: Mar 09, 2010, 2:55 AM
  5. Replies: 2
    Last Post: Aug 27, 2009, 8:12 AM

Tags for this Thread

Posting Permissions