LinkButton.AddParsedSubObject(Object) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
XML veya HTML gibi bir öğenin ayrıştırıldığını denetimi bildirir ve öğeyi denetimin ControlCollection nesnesine ekler.
protected:
override void AddParsedSubObject(System::Object ^ obj);
protected override void AddParsedSubObject (object obj);
override this.AddParsedSubObject : obj -> unit
Protected Overrides Sub AddParsedSubObject (obj As Object)
Parametreler
Örnekler
Aşağıdaki kod örneği, ayrıştırılan nesne bir nesneyse metin özelliğini ayrıştırılmış nesnenin metin özelliğine veya aksi takdirde boş bir dizeye ayarlayan özel LinkButton bir Literal sunucu denetiminde yönteminin nasıl geçersiz kılındığını AddParsedSubObject gösterir.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom LinkButton - AddParsedSubObject - C# Example</title>
<script runat="server">
void LinkButton1_Command(Object sender, CommandEventArgs e)
{
// Redirect to the Microsoft home page.
Response.Redirect("http://www.microsoft.com/");
}
</script>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom LinkButton - AddParsedSubObject - C# Example</h3>
<aspSample:CustomLinkButtonAddParsedSubObject
id="LinkButton1"
runat="server"
OnCommand="LinkButton1_Command"
ToolTip="Microsoft Home">Microsoft Corp.
</aspSample:CustomLinkButtonAddParsedSubObject>
</form>
</body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VS.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom LinkButton - AddParsedSubObject - VB.NET Example</title>
<script runat="server">
Sub LinkButton1_Command(sender As Object, e As CommandEventArgs)
' Redirect to the Microsoft home page.
Response.Redirect("http://www.microsoft.com/")
End Sub
</script>
</head>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom LinkButton - AddParsedSubObject - VB.NET Example</h3>
<aspSample:CustomLinkButtonAddParsedSubObject id="LinkButton1"
runat="server" OnCommand="LinkButton1_Command"
ToolTip="Microsoft Home">Microsoft Corp.</aspSample:CustomLinkButtonAddParsedSubObject>
</form>
</body>
</html>
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomLinkButtonAddParsedSubObject : System.Web.UI.WebControls.LinkButton
{
protected override void AddParsedSubObject(object obj)
{
// If the server control contains any child controls.
if (this.HasControls())
{
// Notify the base server control that an element, either XML or HTML,
// was parsed, and adds the element to the server control's
// ControlCollection object.
base.AddParsedSubObject(obj);
}
else // Else the server control doesn't contain any child controls.
{
// If the parsed element is a LiteralControl.
if (obj is System.Web.UI.LiteralControl)
{
// Set the server control's Text property to the parsed element's Text value.
this.Text = ((System.Web.UI.LiteralControl)obj).Text;
}
else // Else the parsed element is not a LiteralControl.
{
// If the server control has a value in the Text property.
string currentText = this.Text;
if (currentText.Length != 0)
{
// Set the server control's Text property to an empty string.
this.Text = System.String.Empty;
// Notify the base server control that a new LiteralControl was parsed,
// and adds the element to the server control's ControlCollection object.
base.AddParsedSubObject(new System.Web.UI.LiteralControl(currentText));
}
base.AddParsedSubObject(obj);
}
}
}
}
}
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomLinkButtonAddParsedSubObject
Inherits System.Web.UI.WebControls.LinkButton
Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
' If the server control contains any child controls.
If Me.HasControls() Then
' Notify the base server control that an element, either XML or HTML,
' was parsed, and adds the element to the server control's
' ControlCollection object.
MyBase.AddParsedSubObject(obj)
' Else the server control doesn't contain any child controls.
Else
' If the parsed element is a LiteralControl.
If TypeOf obj Is System.Web.UI.LiteralControl Then
' Set the server control's Text property to the parsed element's Text value.
Me.Text = CType(obj, System.Web.UI.LiteralControl).Text
' Else the parsed element is not a LiteralControl.
Else
' If the server control has a value in the Text property.
Dim currentText As String = Me.Text
If currentText.Length <> 0 Then
' Set the server control's Text property to an empty string.
Me.Text = System.String.Empty
' Notify the base server control that a new LiteralControl was parsed,
' and adds the element to the server control's ControlCollection object.
MyBase.AddParsedSubObject(New System.Web.UI.LiteralControl(currentText))
End If
MyBase.AddParsedSubObject(obj)
End If
End If
End Sub
End Class
Şunlara uygulanır
Ayrıca bkz.
GitHub'da bizimle işbirliği yapın
Bu içeriğin kaynağı GitHub'da bulunabilir; burada ayrıca sorunları ve çekme isteklerini oluşturup gözden geçirebilirsiniz. Daha fazla bilgi için katkıda bulunan kılavuzumuzu inceleyin.