Hey guys, I'm having an issue trying to get at the chromestate property for my webparts during run time in an ASP.NET 2.0 app. The webparts themselves are user controls derived from a webpart class. They look, feel and function perfectly, but I would like to trap whether or not their minimized in order to control how many db connections I'm making. Here's an example of how I'm implementing the webparts:
Code:
<%@ Control Language="VB" ClassName="myWebPart" %>
<%@ Implements Interface="System.Web.UI.WebControls.WebParts.IWebPart" %>
<%@ Import Namespace="System.Web.UI.WebControls.WebParts" %>
<%@ Import Namespace="system.Data.sqlclient" %>
<script runat="server">
Private _catalogImageUrl As String = String.Empty
Private _description As String = String.Empty
Private _subTitle As String = ""
Private _title As String = "My Web Part"
Public Property CatalogIconImageUrl() As String Implements IWebPart.CatalogIconImageUrl
Get
Return _catalogImageUrl
End Get
Set(ByVal value As String)
_catalogImageUrl = value
End Set
End Property
Public Property Description() As String Implements IWebPart.Description
Get
Return _description
End Get
Set(ByVal value As String)
_description = value
End Set
End Property
Public ReadOnly Property Subtitle() As String Implements IWebPart.Subtitle
Get
Return String.Empty
End Get
End Property
Public Property Title() As String Implements IWebPart.Title
Get
Return _title
End Get
Set(ByVal _title As String)
End Set
End Property
Public Property TitleIconImageUrl() As String Implements IWebPart.TitleIconImageUrl
Get
Return String.Empty
End Get
Set(ByVal _title As String)
End Set
End Property
Public Property TitleUrl() As String Implements IWebPart.TitleUrl
Get
Return String.Empty
End Get
Set(ByVal _title As String)
End Set
End Property
'Event handlers and such go here
</script>
This works pretty slick as far as all the UI elements are concerned. The problem is I have a metric shit ton of these webparts on an administrative page that all need their own datasets. I would like to refrain from making superflous connections to my database from webparts that are not currently visible. This is something stored in the aformentioned "chromestate" property, which I can't seem to get at.
Basically I'm looking to do something like this:
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Me.ChromeState = "Normal" Then
'Perform all my data aware stuff here
End If
End Sub
Any ideas on how to do this?