Substitution.MethodName Özellik

Tanım

Denetim yürütürken çağrılacak geri çağırma yönteminin Substitution adını alır veya ayarlar.

public:
 virtual property System::String ^ MethodName { System::String ^ get(); void set(System::String ^ value); };
public virtual string MethodName { get; set; }
member this.MethodName : string with get, set
Public Overridable Property MethodName As String

Özellik Değeri

String

Denetim yürütürken çağrılacak yöntemin adını temsil eden Substitution dize.

Örnekler

Aşağıdaki kod örneği, çıktı önbelleğe alınmış bir Substitution Web sayfasına bildirim temelli olarak denetim eklemeyi gösterir. Sayfa yüklendiğinde, kullanıcıya statik bir madde işaretli liste görüntülenir. Sayfanın bu bölümü önbelleğe alınır ve yalnızca 60 saniyede bir güncelleştirilir. Substitution Denetim yürütürken, geçerli kullanıcıyı temsil eden bir dize döndüren yöntemini çağırırGetUser. Bu dize, denetimin sayfadaki konumunda Substitution görüntülenir. Sayfanın bu bölümü önbelleğe alınmaz ve sayfa her yenilendiğinde güncelleştirilir.

<%@ outputcache duration="60" varybyparam="none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" language="C#">  
  
  // The Substitution control calls this method to retrieve
  // the name of the current user from the HttpContext object. 
  // This section of the page is exempt from output caching. 
  public static string GetUser(HttpContext context)
  {
    return context.User.Identity.Name;
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>Substitution.MethodName Property Example</title>
</head>
<body>
  <form id="Form1" runat="server">
  
    <h3>Substitution.MethodName Property Example</h3>  
    
    <!--This section of the page is not cached.-->
    Welcome to the site,
    <asp:substitution id="Substitution1"
      methodname="GetUser"
      runat="Server">
    </asp:substitution>
    
    <br /><br />
    
    <!--This section of the page is cached.-->
    Product list:
    <asp:bulletedlist id="ItemsBulletedList"             
      displaymode="Text" 
      runat="server">    
        <asp:ListItem>Product 1</asp:ListItem>
        <asp:ListItem>Product 2</asp:ListItem>
        <asp:ListItem>Product 3</asp:ListItem>
    </asp:bulletedlist>        

  </form>
</body>
</html>
<%@ outputcache duration="60" varybyparam="none" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server" language="VB">  
  
  ' The Substitution control calls this method to retrieve
  ' the name of the current user from the HttpContext object. 
  ' This section of the page is exempt from output caching. 
  Shared Function GetUser(ByVal context As HttpContext) As String
    Return context.User.Identity.Name
  End Function
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>Substitution.MethodName Property Example</title>
</head>
<body>
  <form id="Form1" runat="server">
  
    <h3>Substitution.MethodName Property Example</h3>  
    
    <!--This section of the page is not cached.-->
    Welcome to the site,
    <asp:substitution id="Substitution1"
      methodname="GetUser"
      runat="Server">
    </asp:substitution>
    
    <br /><br />
    
    <!--This section of the page is cached.-->
    Product list:
    <asp:bulletedlist id="ItemsBulletedList"             
      displaymode="Text" 
      runat="server">    
        <asp:ListItem>Product 1</asp:ListItem>
        <asp:ListItem>Product 2</asp:ListItem>
        <asp:ListItem>Product 3</asp:ListItem>
    </asp:bulletedlist>        

  </form>
</body>
</html>

Açıklamalar

MethodName Denetimi yürütürken Substitution çağrılacak geri çağırma yönteminin adını belirtmek için özelliğini kullanın. Belirttiğiniz geri çağırma yöntemi, sayfada veya denetimi içeren kullanıcı denetiminde Substitution statik bir yöntem olmalıdır. Geri çağırma yönteminin imzası, parametre alan ve dize döndüren bir HttpResponseSubstitutionCallback HttpContext temsilcinin imzası ile eşleşmelidir. Geri çağırma yönteminin döndürdüğü dize, denetimin konumunda Substitution sayfada görüntülenecek içeriktir.

parametresi, HttpContext tek bir HTTP isteği hakkındaki tüm HTTP'ye özgü bilgileri kapsüller. Bunu kullanarak oturum değişkenlerine, yetkilendirme bilgilerine ve kişiselleştirme ayrıntılarına erişebilirsiniz. Daha fazla bilgi için bkz. HttpResponseSubstitutionCallback.

Şunlara uygulanır

Ayrıca bkz.