User control caching

Discussion in 'ASP .Net' started by Liverpool fan, May 10, 2006.

  1. 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
     
    Liverpool fan, May 10, 2006
    #1
    1. Advertising

  2. Shared = "True" still prroduces the same result.
     
    Liverpool fan, May 10, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    454
  2. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    825
    Troy Simpson
    Jan 19, 2004
  3. Mad Scientist Jr
    Replies:
    0
    Views:
    665
    Mad Scientist Jr
    Mar 22, 2006
  4. JimLad
    Replies:
    3
    Views:
    941
    JimLad
    Jan 21, 2010
  5. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    572
    Jonathan Wood
    Feb 2, 2010
Loading...

Share This Page