Take the 2-minute tour ×  I have a requirement where I have to
loop through all the web parts in my page layout whether they
are in WebPartZone or not and render only the webpart instead of
rendering webpart zone.  I am able to loop through for the
WebPartZone, but unfortunately I am not able to loop through the
webparts inside the page.  I have written this code to find the
webpart in a page:  SPLimitedWebPartManager splwManager = web.Ge
tLimitedWebPartManager(HttpContext.Current.Request.Url.ToString(
),
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
foreach (WebPart wprt in splwManager.WebParts.OfType<WebPart>())
but here I am getting the problem that my wprt.Page object is
null. So it's giving me error that "Parameter value cannot be
null. Parameter Required: Page"  Here is the code I have written
for WebPartZone:  WebPartZone webPartZone = Control as
WebPartZone;  if (webPartZone != null)     foreach (WebPart wp
in webPartZone.WebParts)  Looking for someone's help.  Thanks in
adv