public void GetPagesWebPart()
int webPartCount = wpm.WebParts.Count;
WebPartCollection webparts = wpm.WebParts;
for (int i = 0; i < webparts.Count; i++)
{
System.Web.UI.WebControls.WebParts.WebPart webpart = webparts[i];
string partNmae = webpart.Title;
switch (partNmae)
PublicSuccessVWP homeWebpart = webpart as PublicSuccessVWP;
homeWebpart.ProductType = ProductType;
//通过Webpart得到webpart后台类,并遍历获取。
ControlCollection SuccessUsercontrols = webpart.Controls;
foreach (Control item in SuccessUsercontrols)
{
PublicSuccessVWPUserControl PublicSuccessUserControl = item as PublicSuccessVWPUserControl;
if (PublicSuccessUserControl != null)
{
//逻辑代码
}
}
break;
}
}
}
{
//得到当前页面的所有WebPart
WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(this.Page);int webPartCount = wpm.WebParts.Count;
WebPartCollection webparts = wpm.WebParts;
for (int i = 0; i < webparts.Count; i++)
{
System.Web.UI.WebControls.WebParts.WebPart webpart = webparts[i];
string partNmae = webpart.Title;
switch (partNmae)
{
//根据WebPart名称得到指定的WebPart
case "PublicSuccessVWP":PublicSuccessVWP homeWebpart = webpart as PublicSuccessVWP;
homeWebpart.ProductType = ProductType;
//通过Webpart得到webpart后台类,并遍历获取。
ControlCollection SuccessUsercontrols = webpart.Controls;
foreach (Control item in SuccessUsercontrols)
{
PublicSuccessVWPUserControl PublicSuccessUserControl = item as PublicSuccessVWPUserControl;
if (PublicSuccessUserControl != null)
{
//逻辑代码
}
}
break;
}
}
}