帮助PlaceHolders中的用户控件。 [英] Help with user controls within PlaceHolders.

查看:56
本文介绍了帮助PlaceHolders中的用户控件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


感谢您查看我的帖子,感谢任何能为我提供帮助的人。


我从默认页面动态加载用户控件,但是当用户控件中的回发触发时,我无法让所选用户控件重新加载。很难解释所以我会试着告诉你发生了什么。


Default1.aspx

Hello all,

Thanks for looking at my post and thank to anyone that provides me with the help I am looking for.

I dynamically load user controls from a default page but when a postback fires within the user controls I can’t get the selected user control to reload. Hard to explain so I will try to show you what is going on.

Default1.aspx

展开 | 选择 | 换行 | 行号

推荐答案

嘿克罗。尝试重新设置默认页面中的控件
Hey cro. try regestering the control in the default page
展开 | 选择 | Wrap | 行号


感谢您回复yarbrough40。


我知道如何使用<%@ Register%>添加包含。但是,要使用<%@ Register%>在占位符内的运行时动态加载特定用户控件。我还没有。


我认为在注册控件之后我可以在click事件中使用这种语法: myPlaceHolder.Controls.Add(LoadControl(MyControl))但是这不起作用。


我的语法是否正确?


Default1.aspx
Thanks for the reply yarbrough40.

I know how to use the <%@ Register %> to add includes. But, to dynamically loading specific user controls at run time within a placeholder using the <%@ Register %> I have not done.

I would think that after registering the control I could just use this syntax: myPlaceHolder.Controls.Add(LoadControl(MyControl)) within the click event but that does not work.

Do I have the correct syntax?

Default1.aspx
展开 < span class =codeDivider> | 选择 | Wrap | Line数字


嗯 - 我明白了。我还没有做你正在尝试的事情。今天晚些时候,如果你还在失败,我会看看能否让它发挥作用。在你的代码背后尝试首先实例化新控件然后添加它。

如果你直接把它放在页面而不是在运行时加载它我相信它需要看起来像这样:
hmmm - I see. I also have not done what you are attempting. later on today I will see if I can get it to work if you are still failing. In your code behind try first instantiating the new control and then adding that.
If you were to put it in the page directly as opposed to loading it at runtime I believe it would need to look like this:
展开 | 选择 | Wrap | 行号


这篇关于帮助PlaceHolders中的用户控件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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