WizardStepBase.ID 属性
定义
获取或设置分配给服务器控件的编程标识符。Gets or sets the programmatic identifier assigned to the server control.
public:
virtual property System::String ^ ID { System::String ^ get(); void set(System::String ^ value); };
public override string ID { get; set; }
member this.ID : string with get, set
Public Overrides Property ID As String
属性值
分配给控件的编程标识符。The programmatic identifier assigned to the control.
例外
此属性在设计时设置为无效的标识符字符串。The property was set to an invalid identifier string at design time.
- 或 --or- 此属性在设计时设置为与包含 Wizard 控件相同的标识符。The property was set to the same identifier as the containing Wizard control at design time.
- 或 --or- 此属性在设计时设置为与包含 Wizard 控件中的另一个步骤相同的标识符。The property was set to the same identifier as another step in the containing Wizard control at design time.
示例
下面的代码示例为 Wizard Web 窗体页中的控件定义了三个向导步骤。The following code example defines three wizard steps for a Wizard control in a Web Forms page. 在该页的代码中,向导步骤实例按其 ID 值命名,并且可以在代码中引用 WizardStep1 、 WizardStep2 和 WizardStep3 。In code for the page, the wizard step instances are named by their ID values, and they can be referenced in the code as WizardStep1, WizardStep2, and WizardStep3.
<%@ 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 OnActiveStepChanged(object sender, EventArgs e)
{
// If the ActiveStep is changing to Step2 check to see if the
// CheckBox1 CheckBox is checked. If it is then skip
// to the Step3 step.
if (Wizard1.ActiveStep == this.WizardStep2)
{
if (this.CheckBox1.Checked)
{
Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(this.WizardStep3);
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Wizard ID="Wizard1"
Runat="server"
OnActiveStepChanged="OnActiveStepChanged">
<WizardSteps>
<asp:WizardStep ID="WizardStep1"
Title="Step 1"
Runat="server">
<asp:CheckBox ID="CheckBox1"
Runat="Server"
Text="Check this checkbox to skip Step 2." />
You are currently on Step 1.
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2"
Title="Step 2"
Runat="server">
You are currently on Step 2.
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3"
Runat="server"
Title="Step 3">
You are currently on Step 3.
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<b>ActiveStepIndex Example</b>
</HeaderTemplate>
</asp:Wizard>
</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 OnActiveStepChanged(ByVal sender As Object, ByVal e As EventArgs)
' If the ActiveStep is changing to Step2 check to see if the
' CheckBox1 CheckBox is checked. If it is then skip
' to the Step3 step.
If Wizard1.ActiveStep.Equals(Me.WizardStep2) Then
If (Me.CheckBox1.Checked) Then
Wizard1.ActiveStepIndex = Wizard1.WizardSteps.IndexOf(Me.WizardStep3)
End If
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Wizard ID="Wizard1"
Runat="server"
OnActiveStepChanged="OnActiveStepChanged">
<WizardSteps>
<asp:WizardStep ID="WizardStep1"
Title="Step 1"
Runat="server">
<asp:CheckBox ID="CheckBox1"
Runat="Server"
Text="Check this checkbox to skip Step 2." />
You are currently on Step 1.
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2"
Title="Step 2"
Runat="server">
You are currently on Step 2.
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3"
Runat="server"
Title="Step 3">
You are currently on Step 3.
</asp:WizardStep>
</WizardSteps>
<HeaderTemplate>
<b>ActiveStepIndex Example</b>
</HeaderTemplate>
</asp:Wizard>
</form>
</body>
</html>
注解
使用 ID 属性可在 Web 窗体页中标识和引用特定的向导步骤控件。Use the ID property to identify and reference a particular wizard step control in a Web Forms page. ID此值将成为页面中控件实例的名称; 这使你可以轻松访问该页面的代码中的特定步骤。The ID value becomes the name of the control instance in the page; this allows you to easily access a particular step in code for that page. 例如,如果将 ID 控件的属性设置 WizardStepBase 为 "步骤 1",则可以将该页面的代码中的子控件引用为 Step1.Controls 。For example, if you set the ID property of a WizardStepBase control to "Step1", you can reference the child controls of the wizard step in code for that page as Step1.Controls.
WizardStepBase Wizard 当在设计时添加或修改步骤时,控件可确保控件中的每个步骤都具有有效的唯一标识符。The WizardStepBase control ensures that each step in a Wizard control has a valid unique identifier when steps are added or modified at design time. 例如,当你 ID 在设计时设置一个步骤时,它不能与控件中包含的另一步骤的标识符匹配 Wizard ,并且它无法与 ID 包含控件的匹配 Wizard 。For example, when you set the ID for a step at design time, it cannot match the identifier for another step contained in the Wizard control, and it cannot match the ID for the containing Wizard control.