Vinz' Blog

"Code, Beer and Music" ~ my way of being a programmer!
posts - 124, comments - 366, trackbacks - 0

My Links

News

Archives

Image Galleries

WEBPART: Count the number of Closed WebParts within PageCatalogPart

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

Print | posted on Thursday, September 11, 2008 10:48 AM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: