动态添加usercontrol [英] Adding usercontrol dynamically
本文介绍了动态添加usercontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有14个用户控件。
当这14个用户控件添加到主页时动态地从代码后面页面
然后我的主页Page_init ()和Page_Load()事件调用14次
为什么主页加载14次
请帮助
我尝试过:
在主页加载中添加Usercontroll问题
I have 14 User control.
When This 14 User Control added in homepage Dynamically From Code behind Page
Then My Homepage Page_init() and Page_Load() Event Call 14 Times
So Why Homepage Load 14 Times
Please Help
What I have tried:
Adding Usercontroll In Homepage Loading Issue
推荐答案
使用这一个
Use this one
usercontrols_SimpleControl ucSimpleControl =
LoadControl("~/usercontrols/SimpleControl.ascx")
as usercontrols_SimpleControl;
Placeholder1.Controls.Add(ucSimpleControl);
如需更多访问动态加载ASP.NET用户控件 [ ^ ]
我希望这能解决你的问题。
For more visit Dynamic Loading of ASP.NET User Controls[^]
I hope this will resolve your problem.
这篇关于动态添加usercontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文