WebResourceAttribute.PerformSubstitution Özellik

Tanım

Sınıfı tarafından WebResourceAttribute başvuruda bulunulur ekli kaynağın işlenmesi sırasında diğer Web kaynağı URL'lerinin ayrıştırılıp kaynağın tam yolu ile değiştirilip değiştirilmediğini belirleyen bir Boole değeri alır veya ayarlar.

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

Özellik Değeri

true ekli kaynaklar kaynağın işlenmesi sırasında çözümlenirse; aksi takdirde , false. Varsayılan değer: false.

Örnekler

Aşağıdaki kod örneği, özelliğinin değerini sorgulamayı PerformSubstitution gösterir. Bu örnekte, WebResourceAttribute Help.htm HTML dosyasının özniteliği özelliği olarak trueayarlanmış şekilde PerformSubstitution tanımlanır.

Bu kod örneği, sınıfı için WebResourceAttribute sağlanan daha büyük bir örneğin parçasıdır.

<%@ 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>

Bu örnekte kullanılabilecek bir HTML Web kaynağı örneği aşağıda gösterilmiştir. Söz diziminin WebResource , kaynağın PerformSubstitution özelliğini true olarak ayarladığınızda kullanıldığını unutmayın.

<!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>

Açıklamalar

Bir kaynak derlemeden yanıta akışla aktarıldığında, özelliği olarak ayarlandıysa trueekli kaynaklardaki diğer Web kaynaklarına PerformSubstitution başvurular şu anda çözümlenebilir.

Şunlara uygulanır