Geeks With Blogs

News

Microsoft MVP


DZone MVB


Moderator at CodeASP.NET


Quiz Master







free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

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: ,
Posted on Thursday, September 11, 2008 10:48 AM ASP.NET , WebParts | Back to top


Comments on this post: WEBPART: Count the number of Closed WebParts within PageCatalogPart

# re: WEBPART: Count the number of Closed WebParts within PageCatalogPart
Requesting Gravatar...
What is the namespace of that WebParts.
Left by Ben on Jan 11, 2012 7:46 PM

# re: WEBPART: Count the number of Closed WebParts within PageCatalogPart
Requesting Gravatar...
It's System.Web.UI.WebControls.WebParts;

You can check more details here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webpart.aspx
Left by Vinz on Jan 12, 2012 4:56 PM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net