本文整理汇总了C#中System.Web.UI.WebResourceAttribute类的典型用法代码示例。如果您正苦于以下问题:C# WebResourceAttribute类的具体用法?C# WebResourceAttribute怎么用?C# WebResourceAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebResourceAttribute类属于System.Web.UI命名空间,在下文中一共展示了WebResourceAttribute类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WebResource
//引入命名空间
using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
[assembly: WebResource("image1.jpg", "image/jpeg")]
[assembly: WebResource("help.htm", "text/html", PerformSubstitution=true)]
namespace Samples.AspNet.CS.Controls
{
public class MyCustomControl : Control
{
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void CreateChildControls()
{
// Create a new Image control.
Image _img = new Image();
_img.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(MyCustomControl), "image1.jpg");
this.Controls.Add(_img);
// Create a new Label control.
Label _lab = new Label();
_lab.Text = "A composite control using the WebResourceAttribute class.";
this.Controls.Add(_lab);
// Create a new HtmlAnchor control linking to help.htm.
HtmlAnchor a = new HtmlAnchor();
a.HRef = this.Page.ClientScript.GetWebResourceUrl(typeof(MyCustomControl), "help.htm");
a.InnerText = "help link";
this.Controls.Add(new LiteralControl("<br />"));
this.Controls.Add(a);
}
}
}