本文整理汇总了C#中System.Web.UI.WebControls.WebParts.WebPartChrome.WebPartChrome构造函数的典型用法代码示例。如果您正苦于以下问题:C# WebPartChrome构造函数的具体用法?C# WebPartChrome怎么用?C# WebPartChrome使用的例子?那么恭喜您, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Web.UI.WebControls.WebParts.WebPartChrome
的用法示例。
在下文中一共展示了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);
}
}
}