在我的最后一步中,我有一个 for each 循环asp:Wizard
,它应该列出每个文本框中不为空的所有文本。文本框位于第二步,asp:Wizard
它们被放置在asp:Panel
控件中,这些控件在同一步骤中使用复选框可见或不可见。这是带有循环的事件:
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
var requested = this.Controls.OfType<TextBox>()
.Where(txt => !string.IsNullOrWhiteSpace(txt.Text));
var sb = new StringBuilder();
foreach (var textBox in requested)
{
sb.Append(textBox.Text); //Add the text not the textbox
sb.Append("</br>"); //Add a line break to make it look pretty
}
Label1.Text = sb.ToString();
}
如果我使用循环运行应用程序,我的标签将返回空白,无论我填写什么。标签目前处于第三步
<asp:WizardStep ID="WizardStep3" runat="server" AllowReturn="false" Title="Step 3" StepType="Complete">
<asp:Label ID="Label1" runat="server" Text="This text will display when I run the application without the foreach loop"></asp:Label>
</asp:WizardStep>