我想在asp:向导中使用多个步骤自动收集所有信息(即控制值)。怎么做? 我发现了一个有趣的链接,但它无法正常工作:只有一些关于当前步骤的信息:http://msdn.microsoft.com/en-us/library/yt340bh4(v=vs.80).aspx
foreach (Control c in Page.Controls)
{
foreach (Control childc in c.Controls)
{
if (childc is Label)
{
lblTitre0.Text += ((Label)childc).Text + ",";
}
}
}
lblTitre0(asp:label)
中没有数据显示答案 0 :(得分:0)
试试这个
<asp:Wizard runat="server" ID="mainWizard">
<WizardSteps>
<asp:WizardStep>
<asp:Label runat="server" ID="lbl1" Text="Label one" />
</asp:WizardStep>
<asp:WizardStep>
<asp:Label runat="server" ID="lbl2" Text="Label two" />
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<asp:Button runat="server" ID="btnGetall" Text="Get All controls"
OnClick="btn_Click" />
<br />
<asp:Label runat="server" ID="lblResult" />
protected void btn_Click(object sender, EventArgs e)
{
foreach (WizardStep step in mainWizard.WizardSteps)
{
foreach (Control cntrl in step.Controls)
{
if (cntrl is Label)
lblResult.Text += ((Label)cntrl).Text + ",";
}
}
}