如何从另一个usercontrol调用usercontrol load事件? [英] how to call usercontrol load event from another usercontrol?

查看:52
本文介绍了如何从另一个usercontrol调用usercontrol load事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主页,如果用户登录网站菜单并注销usercontrol动态填充。(主页代码端加载usercontrols)



注销菜单有个人资料图片。



有来自masterpage的x.aspx页面。

x.aspx有图像上传usercontrol(非动态)如果我想改变我的个人资料图片我使用这个用户控件但注销图像没有变化。



如果我在上传图像注销图像时单击按钮两次或者我访问菜单注销图像更改?



如何解决这个问题????

I have a masterpage and if user login the site menu and logout usercontrol fill dynamically.(masterpage code side loading usercontrols)

logout menu has profile image.

there is x.aspx page derived from masterpage.
x.aspx has image upload usercontrol(not dynamic)if I want to change my profile image I use this usercontrol but logout image not changing.

if I click button twice when upload image logout image changing or if I visit menu logout image changing ?

how can fix this problem????

推荐答案

没有这样的概念,来电话事件。事件被调用,这与调用非常不同。现在,问题是:在.NET中,除了事件实例的声明类型之外,不可能从任何地方调用任何事件。与普通委托实例相比,这是事件的一个重要的万无一失的功能。如果类型不是你的(比如,你没有源代码,但必须使用库中的某些类型,可能是.NET FCL),并且该类型不提供间接调用该事件的方法或属性,无法以编程方式调用它;你只能在运行时通过操作鼠标或键盘来完成它。



但这绝不需要。您总是可以编写一个可以在两个或多个位置调用的方法:从某个事件处理程序直接调用。您永远不需要调用事件,但您需要以编程方式创建与事件相同的效果。在你的情况下,它甚至更简单:你只需要添加一个用于更改图像的属性。



-SA
There is no such concept, "to call an event". Events are invoked, and this is very different from calling. Now, the thing is: in .NET, it is impossible to invoke any event from anywhere except the declaring type of the event instance. This is an important fool-proof feature of events, in contrast to "normal" delegate instances. If the type is not yours (say, you don't have source code but have to use some type from a library, presumably .NET FCL), and the type does not provide a method or a property which indirectly invokes that events, you cannot programmatically invoke it at all; you can only do it during runtime by operating a mouse or a keyboard.

But this is never needed. You can always write a method which you can call in two or more places: from some event handler and directly. You never really need to invoke an event, but you need to programmatically create the same effect as in case of event. In your case, it's even simpler: you just need to add a property used to change some image.

—SA


这篇关于如何从另一个usercontrol调用usercontrol load事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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