ASP.NET Wizard控件,如何动态添加步骤?
代码隐藏:
public partial class WebForm1 : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
var t = new TemplatedWizardStep { Title = "Lalalal" };
t.Controls.Add(new Step1UserControl());
_WizardWebControl.WizardSteps.Add(t);
base.OnInit(e);
}
}
页面标记:
<asp:Wizard runat="server" id="_WizardWebControl">
Step1UserControl.ascx 标记:
<fieldset>
<legend>General Informations</legend>
<p>TEST DYNAMIC</p>
</fieldset>
该步骤与标题一起显示在左侧栏中,但 HTML(字段集和段落)不显示在该步骤中。它也需要是 TemplatedWizardStep,因为我们使用 Template 进行布局。如何动态添加步骤?
Code-behind:
public partial class WebForm1 : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
var t = new TemplatedWizardStep { Title = "Lalalal" };
t.Controls.Add(new Step1UserControl());
_WizardWebControl.WizardSteps.Add(t);
base.OnInit(e);
}
}
Page markup:
<asp:Wizard runat="server" id="_WizardWebControl">
Step1UserControl.ascx markup:
<fieldset>
<legend>General Informations</legend>
<p>TEST DYNAMIC</p>
</fieldset>
The step show at the left bar with the Title, but the HTML (fieldset and the paragraph) is not displayed in the step. It requires to be a TemplatedWizardStep too because we use Template for the layout. How do I add a Step dynamically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定这种方式是最佳实践,但它有效:
Step1UserControl 应该实现 ITemplate 接口,
然后 onInit 可能如下所示:
I'm not sure that this way is the best practice, but it works:
Step1UserControl should implement ITemplate interface,
and then onInit may look like this: