本文整理汇总了C#中System.Web.UI.WebControls.WebParts.WebPartChrome类的典型用法代码示例。如果您正苦于以下问题:C# WebPartChrome类的具体用法?C# WebPartChrome怎么用?C# WebPartChrome使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebPartChrome类属于System.Web.UI.WebControls.WebParts命名空间,在下文中一共展示了WebPartChrome类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateWebPartChrome
//引入命名空间
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class MyZone : WebPartZone
{
private Boolean _renderVerbsInMenu;
protected override WebPartChrome CreateWebPartChrome()
{
WebPartChrome theChrome = new MyWebPartChrome(this,
this.WebPartManager);
if (RenderVerbsInMenu)
this.WebPartVerbRenderMode = WebPartVerbRenderMode.Menu;
else
this.WebPartVerbRenderMode = WebPartVerbRenderMode.TitleBar;
return theChrome;
}
public Boolean RenderVerbsInMenu
{
get { return _renderVerbsInMenu; }
set { _renderVerbsInMenu = value; }
}
}
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
public class MyWebPartChrome : WebPartChrome
{
WebPartZoneBase theZone;
WebPartManager theManager;
public MyWebPartChrome(WebPartZoneBase aZone, WebPartManager aManager) :
base(aZone, aManager)
{
theZone = aZone;
theManager = aManager;
}
protected override WebPartVerbCollection GetWebPartVerbs(WebPart webPart)
{
ArrayList verbSet = new ArrayList();
foreach (WebPartVerb verb in base.GetWebPartVerbs(webPart))
{
if (verb.Text != "Close")
verbSet.Add(verb);
}
WebPartVerbCollection reducedVerbSet =
new WebPartVerbCollection(verbSet);
return reducedVerbSet;
}
protected override Style CreateWebPartChromeStyle(WebPart part,
PartChromeType chromeType)
{
Style finalStyle = new Style();
finalStyle.CopyFrom(base.CreateWebPartChromeStyle(part, chromeType));
finalStyle.Font.Name = "Verdana";
return finalStyle;
}
protected override void RenderPartContents(HtmlTextWriter writer,
WebPart part)
{
if (part == this.WebPartManager.SelectedWebPart)
HttpContext.Current.Response.Write("<span>Not rendered</span>");
else
if(this.Zone.GetType() == typeof(MyZone))
part.RenderControl(writer);
}
}
}