用户控件的页面调用功能 [英] Call function of page from usercontrol

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

问题描述


我正在使用一个用户控件uc.ascx.我已将用户控件添加到页面Default.aspx中.我想在用户控件中调用页面Default.aspx的函数.

是否有可能,如果有人知道请帮助..

谢谢

Nidhin

Hi
I''m using a usercontrol uc.ascx. I have added the usercontrol to page Default.aspx. I want to call a function of the page Default.aspx in the usercontrol.

Is it possible, if any one knows please help..

Thanks

Nidhin

推荐答案

做到这一点的最佳方法是在控件和hte页面之间连接一个委托,以便控件可以向该页面发送消息.一种更硬编码的方法,其中控件需要知道包含它的页面的详细信息,这表明您的页面设计已损坏,并且您的控件实际上不值得编写为控件,它应该只存在于页面中
The best way to do this is to hook up a delegate between the control and hte page, so that the control can send a message to the page. A more hard coded approach, where the control needs to know the specifics of the page that contains it, is a sign that your page design is broken, and your control is not really worth writing as a control, it should just live in the page, or be better engineered.


为此,一种方法是在app_code文件夹中创建一个抽象类,该类必须具有抽象方法.通过此类继承您的页面并覆盖该方法.您可以在usercontrol中访问的方法.

例如,请查看链接
For that, one way is create an abstract class in app_code folder, which must have an abstract method.Inherit your page by this class and override the method.This method you can access in usercontrol.

For example , have a look to the Link


请不要"t按"答案"再问一个问题.

此处" 课程 [ ^ ],程序员在这种情况下会做什么.
Please don''t push ''answer'' to ask another question.

Here''s a lesson[^] in what programmers do in a situation like this.


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

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