我正在构建一个网站,我需要根据用户请求调用 WebUserControls (.ascx),我该如何实现?这可能吗?
例子:
protected void userclick_click(object sender, EventArgs e)
{
if(textbox1.Text == "2")
{
call WebUserControl1.ascx
}
else
{
/*do nothing*/
}
}
我为此使用 C#。
提前谢谢你。
最佳答案
protected void userclick_click(object sender, EventArgs e)
{
if(textbox1.Text == "2")
{
Control c1 = LoadControl("MyUserControl.ascx");
//page or whatever control you want to add to
Page.Controls.Add(c1);
}
else
{
/*do nothing*/
}
}
关于c# - 如何根据用户请求调用 WebUserControls?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7655615/