The following snippets below checks whether the PageCatalogPart Control contains any available WebParts in a page that have been closed in the page..
C#
protected void PageCatalogPart1_Load(object sender, EventArgs e)
{
int count = 0;
if (WebPartManager1.WebParts.Count > 0)
{
for (int i = 0; i < WebPartManager1.WebParts.Count; i++)
{
WebPart wp = (WebPart)WebPartManager1.WebParts[i];
if (wp.IsClosed)
{
Response.Write("Page Catalog contains Closed WebParts");
count++;
}
}
Response.Write("<br/>Tolal closed WebParts: " + count.ToString());
}
}
VB.NET
Protected Sub PageCatalogPart1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim count As Integer = 0
If WebPartManager1.WebParts.Count > 0 Then
For i As Integer = 0 To WebPartManager1.WebParts.Count - 1
Dim wp As WebPart = DirectCast(WebPartManager1.WebParts(i), WebPart)
If wp.IsClosed Then
Response.Write("Page Catalog contains Closed WebParts")
count += 1
End If
Next
Response.Write("<br/>Tolal closed WebParts: " + count.ToString())
End If
End Sub
Technorati Tags:
ASP.NET,
WebParts