HtmlForm.UniqueID Eigenschap
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Hiermee haalt u de unieke programmatische id op die aan het HtmlForm besturingselement is toegewezen.
public:
virtual property System::String ^ UniqueID { System::String ^ get(); };
public override string UniqueID { get; }
member this.UniqueID : string
Public Overrides ReadOnly Property UniqueID As String
Waarde van eigenschap
De unieke programmatische id die aan het HtmlForm besturingselement is toegewezen.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de UniqueID eigenschap gebruikt om de unieke id voor een HtmlForm besturingselement op te halen.
<%@ page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="Server">
void Button1_Click(object sender, System.EventArgs e)
{
// Write the form's UniqueID to the specified Label control.
Label1.Text = "The HtmlForm control's UniqueID is "
+ Form1.UniqueID + ".";
}
void Button2_Click(object sender, System.EventArgs e)
{
// Write the button's UniqueID to the specified Label control.
Label2.Text = "This Button control's UniqueID is "
+ Button2.UniqueID + ".";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlForm UniqueID Property Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<h3>HtmlForm UniqueID Property Example</h3>
<asp:button id="Button1"
text="Get the form's UniqueID"
onclick="Button1_Click"
runat="server">
</asp:button>
<asp:label id="Label1"
runat="Server">
</asp:label>
<br />
<asp:button id="Button2"
text="Get this button's UniqueID"
onclick="Button2_Click"
runat="server">
</asp:button>
<asp:label id="Label2"
runat="server">
</asp:label>
</form>
</body>
</html>
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' Write the form's UniqueID to the specified Label control.
Label1.Text = "The HtmlForm control's UniqueID is " _
& Form1.UniqueID + "."
End Sub
Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' Write the button's UniqueID to the specified Label control.
Label2.Text = "This Button control's UniqueID is " _
& Button2.UniqueID & "."
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HtmlForm UniqueID Property Example</title>
</head>
<body>
<form id="Form1"
runat="server">
<h3>HtmlForm UniqueID Property Example</h3>
<asp:button id="Button1"
text="Get the form's UniqueID"
onclick="Button1_Click"
runat="server">
</asp:button>
<asp:label id="Label1"
runat="Server">
</asp:label>
<br />
<asp:button id="Button2"
text="Get this button's UniqueID"
onclick="Button2_Click"
runat="server">
</asp:button>
  ;
<asp:label id="Label2"
runat="server">
</asp:label>
</form>
</body>
</html>
Opmerkingen
Gebruik de UniqueID eigenschap om de unieke programmatische id op te halen die aan het HtmlForm besturingselement is toegewezen. Met deze eigenschap wordt de basis-implementatie overschreven om een constante waarde te retourneren wanneer het besturingselement is opgenomen in een INamingContainerander object dan een pagina, zoals een aangepast serverbesturingselement. Als de naamgevingscontainer een pagina is, wordt de waarde van de eigenschap van het HtmlForm besturingselement ID geretourneerd.
De UniqueID eigenschap en de Name eigenschap retourneren altijd dezelfde waarde. Dit is handig wanneer het HtmlForm besturingselement wordt weergegeven in een browser waarvoor de eigenschappen en Name eigenschappen van het HtmlForm besturingselement UniqueID hetzelfde moeten zijn. Om deze eigenschappen gesynchroniseerd te houden, retourneert de Name eigenschap altijd de waarde van de UniqueID eigenschap.
Note
Het kenmerk name is geen XHTML-compatibel kenmerk en wordt standaard niet weergegeven door ASP.NET.