WebResourceAttribute.PerformSubstitution WebResourceAttribute.PerformSubstitution WebResourceAttribute.PerformSubstitution WebResourceAttribute.PerformSubstitution Property

定義

WebResourceAttribute クラスによって参照される埋め込みリソースの処理中に、他の Web リソース URL を解析し、リソースの完全パスに置き換えるかどうかを示すブール値を取得または設定します。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.

public:
 property bool PerformSubstitution { bool get(); void set(bool value); };
public bool PerformSubstitution { get; set; }
member this.PerformSubstitution : bool with get, set
Public Property PerformSubstitution As Boolean

プロパティ値

リソースの処理中に埋め込みリソースを解決する場合は true。それ以外の場合は falsetrue if embedded resources are resolved during processing of the resource; otherwise, false. 既定値は、false です。The default is false.

次のコード例は、 PerformSubstitutionプロパティの値に対してクエリを実行する方法を示しています。The following code example demonstrates how to query the value of the PerformSubstitution property. この例では、 WebResourceAttribute HTML ファイルのヘルプ .htm の属性は、 PerformSubstitutionプロパティをにtrue設定して定義されています。In this example, the WebResourceAttribute attribute of the HTML file Help.htm is defined with the PerformSubstitution property set to true.

このコード例は、 WebResourceAttributeクラスに対して提供される大規模な例の一部です。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>
<%@ Page Language="VB" %>
<%@ Register TagPrefix="AspNetSamples" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB.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 Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Get the assembly metatdata.
    Dim clsType As Type = GetType(MyCustomControl)
    Dim a As Assembly = clsType.Assembly
    
    For Each attr As Attribute In Attribute.GetCustomAttributes(a)
      'Check for WebResource attributes.
      If attr.GetType() Is GetType(WebResourceAttribute) Then
        Dim wra As WebResourceAttribute = CType(attr, WebResourceAttribute)
        Response.Write("Resource in the assembly: " & wra.WebResource.ToString() & _
        " with ContentType = " & wra.ContentType.ToString() & _
        " and PerformsSubstitution = " & wra.PerformSubstitution.ToString() & "</br>")
      End If
    Next attr
    
    
  End Sub
  
</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>

この例で使用できる HTML Web リソースの例を次に示します。An example of an HTML Web resource that could be used in this example is shown next. リソースに対しWebResourcePerformSubstitutionプロパティをにtrue設定するときに、構文が使用されていることに注意してください。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 >

<head>

<title>Included Help Page</title>

</head>

<body>

<div>

<img alt="help image" src=<% = WebResource("image1.jpg") %> />

Included help file.

</div>

</body>

</html>

注釈

リソースがアセンブリから応答にストリームされるとき、このプロパティがにPerformSubstitution true設定されている場合、埋め込みリソース内の他の Web リソースへの参照を現時点で解決できます。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.

適用対象