在运行时加载userControl并将其放入Panel中 [英] Load userControl at runtime and putup it into Panel

查看:121
本文介绍了在运行时加载userControl并将其放入Panel中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,





请在我的下面情景中建议我,我应该使用什么?



我想动态加载usercontrol,即当我点击按钮时,我想加载我的usercontrol并把它放到Panel中。

所以我必须使用哪种技术..



我想避免在页面加载时不必要的加载usercontrol数据。我想在需要时加载它。





请建议我..

Hello Guys,


Please suggest me on my below scenario,what i should used?

I want to Load usercontrol Dynamically,i.e. when i click on Button that time I want to Load my usercontrol and put up it into Panel.
so which technique i have to used for that..

I want to avoid unneccessary loading usercontrol data on Page load.I want to load it when i required.


Please suggest me about that..

推荐答案

.NET在Page类中有一个LoadControl方法,使用它可以创建UserControl的实例。然后,您可以使用panel1.Controls.Add(control)将其添加到页面;



请参阅此链接以供参考: http://msdn.microsoft.com/en-us/library/t9ecy7tf.aspx [ ^ ]



希望这有助于: - )
.NET has a LoadControl method in the Page class, using this you can create an instance of a UserControl. You can then add that to the page using panel1.Controls.Add(control);

See this link for reference: http://msdn.microsoft.com/en-us/library/t9ecy7tf.aspx[^]

Hope this helps :-)


这篇关于在运行时加载userControl并将其放入Panel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆