Feb 17, 2009, 5:12 PM
[CLOSED] Portal Resize Ajax Event fires on page load... not just on the resize
I am trying to capture the resize event on a portal, but it seems to be firing on the page load and also when the tab is clicked on (activated), this is causing my to record some incorrect values for the width of the portal in my database. Is there a way to keep my resize function from firing unless the portal was resized by dragging the mouse?
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Page3.aspx.vb" Inherits="HomePage.Page3" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Microsoft.ApplicationBlocks.Data" %>
<%@ Import Namespace="Helpers" %>
<%@ Import Namespace="Helpers.FormatHelpers" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
<title>The Magazine Manager</title>
<script runat="server">
Dim Portal2Width As Integer
Private PortalID As Integer = 0
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'add the logged in user as a javascript variable so we can use it
Dim cs As String = Connection.ConnectionString(Request.ServerVariables("SERVER_NAME"))
'load the navigation menu
If Not Page.IsPostBack Then
'set up portlets
CreateAllPortals()
End If
End Sub
Public Sub CreateAllPortals()
'create each portal defined for this user
Dim PortalIndex As Integer = 1
'set up this portal
Dim tabPortal As Tab = FindControl("TabPortal" & PortalIndex)
tabPortal.Title = "Portal " & PortalIndex
'set the width of the second portal and store in in the array
Dim PortalTemp As Portal = FindControl(String.Format("Portal{0}_1", PortalIndex))
PortalTemp.Width = Null2Integer(500)
'set up column1
CreatePortletColumn(PortalIndex, 1)
'set up column2
CreatePortletColumn(PortalIndex, 2)
'create the portal
PortalTemp.DoLayout()
tabPortal.Show()
'move to the next portal page/tab
PortalIndex += 1
'set up this portal
tabPortal = FindControl("TabPortal" & PortalIndex)
tabPortal.Title = "Portal " & PortalIndex
'set the width of the second portal and store in in the array
PortalTemp = FindControl(String.Format("Portal{0}_1", PortalIndex))
PortalTemp.Width = 500
'set up column1
CreatePortletColumn(PortalIndex, 1)
'set up column2
CreatePortletColumn(PortalIndex, 2)
'create the portal
PortalTemp.DoLayout()
tabPortal.Show()
End Sub
Private Sub CreatePortletColumn(ByVal PortalIndex As Integer, ByVal ColumnIndex As Integer)
Dim n As Integer
For n = 0 To 1
Dim ID As String = n
Dim Title As String = "Portlet" & n
Dim PageURL As String = "http://www.ext.net"
Dim Collapsible As Boolean = True
Dim Closeable As Boolean = True
Dim Draggable As Boolean = True
Dim Collapsed As Boolean = True
Dim Height As Integer = 250
Dim PortletTemp As New Portlet
PortletTemp.ID = String.Format("Component{0}_{1}_{2}", PortalIndex, ColumnIndex, ID)
PortletTemp.Title = Title
If Height > 0 Then
PortletTemp.Height = Height
End If
PortletTemp.Collapsed = Collapsed
PortletTemp.StyleSpec = "padding:10px;"
If Not Collapsed Then
'load the URL in the portlet
Dim al As New LoadConfig
al.Url = PageURL
al.ShowMask = True
al.Mode = LoadMode.IFrame
PortletTemp.Load(al)
Else
PortletTemp.Listeners.Expand.Handler = "this.load({url:'http://www.ext.net',mode:'iframe', showMask:true});"
PortletTemp.Listeners.Expand.Single = True
End If
'add listeners to call AJAX to save the collapse and expand states
PortletTemp.Collapsible = Collapsible.ToString
'can we drag this portlet to a new position?
PortletTemp.Draggable = Draggable
Dim AnchorTemp As New Anchor
AnchorTemp.Horizontal = "100%"
AnchorTemp.Items.Add(PortletTemp)
Dim AnchorLayoutTemp As AnchorLayout = FindControl(String.Format("AnchorLayoutPortal{0}_{1}", PortalIndex, ColumnIndex))
AnchorLayoutTemp.Anchors.Add(AnchorTemp)
Next
End Sub
Public Sub Resize_Portal(ByVal sender As Object, ByVal e As AjaxEventArgs)
Dim PortalIndex As Integer = e.ExtraParams("PortalIndex")
Dim Width As String = e.ExtraParams("Width")
CType(FindControl(String.Format("TabPortal{0}", PortalIndex)), Tab).Title = "resize-" & Width & ":" & Now()
End Sub
</script>
<script type="text/javascript"></script>
<style type="text/css"></style>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" />
<ext:ViewPort ID="ViewPort1" runat="server">
<Body>
<ext:BorderLayout ID="BorderLayout1" runat="server">
<Center>
<ext:Panel ID="Panel7" runat="server" AutoScroll="true">
<Body>
<ext:FitLayout ID="FitLayout2" runat="server">
<ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Plain="true" LayoutOnTabChange="true" EnableTabScroll="true">
<Tabs>
<ext:Tab ID="TabPortal1" runat="server" Title="" ShowIFrameMask="true" AutoScroll="true">
<Body>
<ext:BorderLayout ID="BorderLayoutPortal1" runat="server">
<West Split="true" Collapsible="false" Margins-Top=0>
<ext:Portal ID="Portal1_1" runat="server" Border="false" AutoHeight="true">
<Body>
<ext:ColumnLayout ID="ColumnLayoutPortal1_1" runat="server">
<ext:LayoutColumn ColumnWidth=".99">
<ext:PortalColumn ID="PortalColumnPortal1_1" runat="server" StyleSpec="padding:5px 5px 5px 5px">
<Body>
<ext:AnchorLayout ID="AnchorLayoutPortal1_1" runat="server">
</ext:AnchorLayout>
</Body>
</ext:PortalColumn>
</ext:LayoutColumn>
</ext:ColumnLayout>
</Body>
<AjaxEvents>
<Resize OnEvent="Resize_Portal">
<ExtraParams>
<ext:Parameter Name="PortalIndex" Value="1" Mode="Raw" />
<ext:Parameter Name="Width" Value="adjWidth" Mode="Raw" />
</ExtraParams>
</Resize>
</AjaxEvents>
</ext:Portal>
</West>
<Center>
<ext:Portal ID="Portal1_2" runat="server" Border="false" AutoHeight="true">
<Body>
<ext:ColumnLayout ID="ColumnLayoutPortal1_2" runat="server">
<ext:LayoutColumn ColumnWidth=".99">
<ext:PortalColumn ID="PortalColumnPortal1_2" runat="server" StyleSpec="padding:10px 10px 10px 10px">
<Body>
<ext:AnchorLayout ID="AnchorLayoutPortal1_2" runat="server">
</ext:AnchorLayout>
</Body>
</ext:PortalColumn>
</ext:LayoutColumn>
</ext:ColumnLayout>
</Body>
</ext:Portal>
</Center>
</ext:BorderLayout>
</Body>
</ext:Tab>
<ext:Tab ID="TabPortal2" runat="server" Title="Portal 2" ShowIFrameMask="true" AutoScroll="true">
<Body>
<ext:BorderLayout ID="BorderLayoutPortal2" runat="server">
<West Split="true" Collapsible="false" Margins-Top=0>
<ext:Portal ID="Portal2_1" runat="server" Border="false" AutoHeight="true">
<Body>
<ext:ColumnLayout ID="ColumnLayoutPortal2_1" runat="server">
<ext:LayoutColumn ColumnWidth=".99">
<ext:PortalColumn ID="PortalColumnPortal2_1" runat="server" StyleSpec="padding:5px 5px 5px 5px">
<Body>
<ext:AnchorLayout ID="AnchorLayoutPortal2_1" runat="server">
</ext:AnchorLayout>
</Body>
</ext:PortalColumn>
</ext:LayoutColumn>
</ext:ColumnLayout>
</Body>
<AjaxEvents>
<Resize OnEvent="Resize_Portal">
<ExtraParams>
<ext:Parameter Name="PortalIndex" Value="2" Mode="Raw" />
<ext:Parameter Name="Width" Value="adjWidth" Mode="Raw" />
</ExtraParams>
</Resize>
</AjaxEvents>
</ext:Portal>
</West>
<Center>
<ext:Portal ID="Portal2_2" runat="server" Border="false" AutoHeight="true">
<Body>
<ext:ColumnLayout ID="ColumnLayoutPortal2_2" runat="server">
<ext:LayoutColumn ColumnWidth=".99">
<ext:PortalColumn ID="PortalColumnPortal2_2" runat="server" StyleSpec="padding:10px 10px 10px 10px">
<Body>
<ext:AnchorLayout ID="AnchorLayoutPortal2_2" runat="server">
</ext:AnchorLayout>
</Body>
</ext:PortalColumn>
</ext:LayoutColumn>
</ext:ColumnLayout>
</Body>
</ext:Portal>
</Center>
</ext:BorderLayout>
</Body>
</ext:Tab>
</Tabs>
</ext:TabPanel>
</ext:FitLayout>
</Body>
</ext:Panel>
</Center>
</ext:BorderLayout>
</Body>
</ext:ViewPort>
</form>
</body>
</html>
Last edited by geoffrey.mcgill; Feb 22, 2011 at 4:12 AM.