User control caching

L

Liverpool fan

I have a simple user control that consists of a lebel and a dropdown
list that I am using for page navigation. I want to cache this control
so that it is reused between pages, however when I add the OutputCache
directive, the control no longer responds to events What am I doing
wrong?

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="AssetType.ascx.vb" Inherits="AssetRegister.AssetType"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ OutputCache Duration="60" VaryByParam="None" Shared="None" %>

Public Class AssetType
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents ddlAssetType As
System.Web.UI.WebControls.DropDownList

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Try
If Not Me.IsPostBack Then
Me.ddlAssetType.SelectedValue =
Me.Session("AssetType").ToString
End If
Catch ex As Exception

End Try
End Sub

Private Sub ddlAssetType_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ddlAssetType.SelectedIndexChanged
Dim sPage As String = ""
Dim sAssetType As String = ""

Select Case Me.ddlAssetType.SelectedValue
Case "PC's"
sPage = "PCs.aspx"
sAssetType = "PC's"
Case "Notebooks"
sPage = "Notebooks.aspx"
sAssetType = "Notebooks"
Case "Servers"
sPage = "Servers.aspx"
sAssetType = "Servers"
Case "Printers - Windows"
sPage = "PrintersWin.aspx"
sAssetType = "Printers - Windows"
Case "Printers - GSM"
sPage = "PrintersGSM.aspx"
sAssetType = "Printers - GSM"
Case "Printers - Local"
sPage = "PrintersLocal.aspx"
sAssetType = "Printers - Local"
Case "Mobiles"
sPage = "UserMobiles.aspx"
sAssetType = "Mobiles"
Case "Multiplexors"
sPage = "Multiplexors.aspx"
sAssetType = "Multiplexors"
Case "Miscellaneous"
sPage = "Misc.aspx"
sAssetType = "Miscellaneous"
End Select

If sPage <> "" AndAlso sAssetType <> "" Then
Me.Session("AssetType") = sAssetType
Me.Response.Redirect(sPage)
End If

End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top