Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

WebResourceAttribute.PerformSubstitution Property

Gets or sets a Boolean value that determines whether, during processing of the embedded resource referenced by the WebResourceAttribute class, other Web resource URLs are parsed and replaced with the full path to the resource.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
public bool PerformSubstitution { get; set; }
/** @property */
public boolean get_PerformSubstitution ()

/** @property */
public void set_PerformSubstitution (boolean value)

public function get PerformSubstitution () : boolean

public function set PerformSubstitution (value : boolean)

Not applicable.

Property Value

true if embedded resources are resolved during processing of the resource; otherwise, false. The default is false.

When a resource is streamed from the assembly to the response, references to other Web resources in the embedded resources can be resolved at this time, if the PerformSubstitution property is set to true.

The following code example demonstrates how to query the value of the PerformSubstitution property. In this example, the WebResourceAttribute attribute of the HTML file Help.htm is defined with the PerformSubstitution property set to true.

This code example is part of a larger example provided for the WebResourceAttribute class.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS.Controls" %>
<%@ Import Namespace="System.Reflection" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
  {
            
    // Get the assembly metatdata.
    Type clsType = typeof(MyCustomControl);
    Assembly a = clsType.Assembly;

    // Iterate through the attributes for the assembly.
    foreach (Attribute attr in Attribute.GetCustomAttributes(a))
    {
      //Check for WebResource attributes.
      if (attr.GetType() == typeof(WebResourceAttribute))
      {
        WebResourceAttribute wra = (WebResourceAttribute)attr;
        Response.Write("Resource in the assembly: " + wra.WebResource.ToString() +
          " with ContentType = " + wra.ContentType.ToString() +
          " and PerformsSubstitution = " + wra.PerformSubstitution.ToString() + "</br>");
      }
    }
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebResourceAttribute Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <AspNetSamples:MyCustomControl id="MyCustomControl1" runat="server">
      </AspNetSamples:MyCustomControl>    
    </div>
    </form>
</body>
</html>

An example of an HTML Web resource that could be used in this example is shown next. Note that the WebResource syntax is used when you set the PerformSubstitution property to true for the 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>

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.