WebResourceAttribute Class
Defines the metadata attribute that enables an embedded resource in an assembly. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
The WebResourceAttribute class is valid only when used on assembly declarations. It is used to enable a specified embedded resource in an assembly for use as a Web resource.
For more information on resources, see ASP.NET Web Page Resources Overview.
This section contains two code examples. The first code example demonstrates how to apply the WebResourceAttribute attribute to a namespace that defines a custom control, MyCustomControl. The second code example demonstrates how to use the MyCustomControl class in a Web page.
The following code example demonstrates how to apply the WebResourceAttribute attribute on a custom assembly to define an image Web resource and an HTML Web resource. The MyCustomControl class defines a composite control that uses the resources to set the value of the ImageUrl property of an Image control that is contained within the composite control and to set the HRef property of an HtmlAnchor control linking to the HTML resource.
The following code example demonstrates how to use the MyCustomControl class in a Web page.
This example requires that you compile the Image1.jpg and Help.htm resources with the assembly that contains MyCustomControl. For more information, see, /resource (Embed Resource File to Output) (C# Compiler Options) or /resource (Visual Basic).
An example of an HTML Web resource that could be used in this example is shown next. Note the use of the WebResource syntax, which is used when you set the PerformSubstitution property to true for a Web resource.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Included Help Page</title>
</head>
<body>
<div>
<img alt="help image" src=<% = WebResource("image1.jpg") %> />
Included help file.
</div>
</body>
</html>
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.