Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Initialisiert eine neue Instanz der ConstructorNeedsTagAttribute-Klasse.
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Public Sub New ( _
needsTag As Boolean _
)
'Usage
Dim needsTag As Boolean
Dim instance As New ConstructorNeedsTagAttribute(needsTag)
public ConstructorNeedsTagAttribute (
bool needsTag
)
public:
ConstructorNeedsTagAttribute (
bool needsTag
)
public ConstructorNeedsTagAttribute (
boolean needsTag
)
public function ConstructorNeedsTagAttribute (
needsTag : boolean
)
Parameter
- needsTag
true, um einem Steuerelement ein Tag hinzuzufügen, andernfalls false.
Beispiel
Im folgenden Codebeispiel wird ein einfaches benutzerdefiniertes Steuerelement erstellt, dessen Tagname zur Laufzeit definiert wird. Die Befehlszeile zum Erstellen der ausführbaren Datei lautet wie folgt:
vbc /r:System.dll /r:System.Web.dll /t:library /out:myWebAppPath/Bin/vb_myconstructorNeedsTagAtt.dll constructNeedsTagAtt.vb
csc /t:library /out:myWebAppPath/Bin/cs_myConstructorNeedsTagAtt.dll constructorNeedsTagAtt.cs
' File name: constructorneedstagatt.cs.
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Namespace MyUserControl
<ConstructorNeedsTagAttribute(True)> _
Public Class Simple
Inherits WebControl
Private NameTag As [String] = ""
Public Sub New(tag As [String])
Me.NameTag = tag
End Sub 'New
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(output As HtmlTextWriter)
output.Write(("<br>The TagName used for the 'Simple' control is " + "'" + NameTag + "'"))
End Sub 'Render
End Class 'Simple
End Namespace 'MyUserControl
/* File Name: constructorneedstagatt.cs. */
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace MyUserControl
{
// Attach the 'ConstructorNeedsTagAttribute' to 'Simple' class.
[ConstructorNeedsTagAttribute(true)]
public class Simple : WebControl
{
private String NameTag = "";
public Simple(String tag)
{
this.NameTag = tag;
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void Render(HtmlTextWriter output)
{
output.Write("<br>The TagName used for the 'Simple' control is "+"'"+NameTag+"'");
}
}
}
package MyUserControl;
/* File Name: constructorneedstagatt.jsl. */
import System.*;
import System.Web.*;
import System.Web.UI.*;
import System.Web.UI.WebControls.*;
import System.ComponentModel.*;
// Attach the 'ConstructorNeedsTagAttribute' to 'Simple' class.
/** @attribute ConstructorNeedsTagAttribute(true)
*/
public class Simple extends WebControl
{
private String nameTag = "";
public Simple(String tag)
{
this.nameTag = tag;
} //Simple
protected void Render(HtmlTextWriter output)
{
output.Write("<br>The TagName used for the 'Simple' control is "
+ "'" + nameTag + "'");
} //Render
} //Simple
Im folgenden Codebeispiel wird das vorherige benutzerdefinierte Steuerelement verwendet. Beachten Sie, dass die in der Register-Direktive dargestellten Werte die vorherige Befehlszeile widerspiegeln.
<%@ Register TagPrefix='MyCurrentUserControl' Namespace='MyUserControl' Assembly='vb_myConstructorNeedsTagAtt'%>
<html>
<body>
<form method="POST" runat="server">
<MyCurrentUserControl:Simple runat="server" />
</form>
</body>
</html>
<%@ Register TagPrefix='MyCurrentUserControl' Namespace='MyUserControl' Assembly='cs_myConstructorNeedsTagAtt'%>
<html>
<body>
<form method="POST" runat="server">
<MyCurrentUserControl:Simple runat="server" />
</form>
</body>
</html>
Plattformen
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
ConstructorNeedsTagAttribute-Klasse
ConstructorNeedsTagAttribute-Member
System.Web.UI-Namespace