简体   繁体   English

.NET事件在Winform中比Webform更常见?

[英].NET Events more common in winform than webform?

正在申报自定义.NET事件如 ,比网页表单一个winform应用程序更常见?

Custom events are probably a bit more rare in webforms compared to winforms, since http is stateless. 自定义事件在Web窗体中可能比Winforms少一些,因为http是无状态的。 So in many cases, a user action you want to react on, often come in form as a request, where you use the querystring parameters to determine what and how to react. 因此,在许多情况下,您希望做出反应的用户动作通常以请求的形式出现,您可以在其中使用querystring参数确定做出什么反应以及如何做出反应。

But i still find custom events very useful in my ascx usercontrols, because its an easy way to hide details about how the user control works internally, and just expose an event that the page can react on when interesting stuff happens. 但是我仍然发现自定义事件在我的ascx用户控件中非常有用,因为它是一种隐藏有关用户控件内部工作方式的详细信息的简便方法,并且仅公开事件可以在有趣的事件发生时对页面进行响应。

在文本中搜索关键字“ event”(注意末尾的空格)将很好地表明暴露自定义事件的类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM