如何从类(.cs)调用aspx.cs事件 [英] how to call aspx.cs event from class (.cs)

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

问题描述


我想从我的class1.cs中调用Default.aspx.cs页面的事件
帮帮我.
谢谢.

Hi,
I want to call event of Default.aspx.cs page from my class1.cs
help Me.
Thank u.

推荐答案

如果在您指的页面回发期间,您可以执行
If it is during the postback of the page you are referring to you can do
(Page)System.Web.HttpContext.Current.CurrentHandler



这会将当前的回发会话转换为一个Page,您可以将其转换为具有您的网页的类,然后调用该函数.

但是,这些评论是正确的,这是糟糕的体系结构.您确实需要以不同的方式来做.



This will convert the current postback session into a Page which you can convert to the class that has your webpage and then call the function.

However, the comments are correct, this is bad architecture to do this. You really need to look at doing it a different way.


这篇关于如何从类(.cs)调用aspx.cs事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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