ASP.NET进展 [英] ASP.NET Progress

查看:70
本文介绍了ASP.NET进展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您的事件处理程序必须是非静态的怎么办?

What if your event handler has to be nonstatic?

推荐答案

Navyjax2,您能否提供有关您所面临问题的更多信息?


有一个 INotifyPropertyChanged.PropertyChanged事件。当这个事件被提出时,它表示该物业已被更改。



-Frinny
Navyjax2, could you please provide more information about the problem you are facing?

There is the INotifyPropertyChanged.PropertyChanged Event. When this event is raised it indicates that the property has been changed.



-Frinny


和我一起裸露我对代表,接口和事件都很陌生,尽管我已经做了近2年的C#和VB6以来的VB / VB .NET。


基本上我想在变量'的值发生变化时做一个事件。当通过foreach循环解析DataTable时,公共变量值(本质上是计数器)会增加。变量'的值改变将触发一个事件,该事件将改变页面上的span标记的innerHTML(必须在非静态函数内发生),以指示我们在整个行中的行 - 创建
类似于:
Bare with me, I''m fairly new to delegates, interfaces, and events, even though I''ve been doing C# for almost 2 yrs and VB/VB .NET since VB6.

Basically I wanted to do an event whenever a variable''s value changed. A public variable value (essentially a counter) is increased as a DataTable is parsed through a foreach loop. The variable''s value changing would trigger an event that would change the innerHTML of a span tag on the page (which has to happen within a nonstatic function), to give an indication of what row we were on out of the total - creating a progress counter.

Something like:
展开 | 选择 | Wrap < span class =codeDivider> | 行号


我认为处理此问题的最简单方法是将公共变量设为私有,并提供公共属性。这样你的属性就可以引发一个事件来通知所有其他类的变化......或者它可以改变元素的innerHTML(不知道为什么你这样做但是确定)。

封装适合你的时候很好:)


-Frinny
I think that the easiest way to handle this is to make the public variable private and provide a public Property instead. That way your property could either raise an event that notifies all other classes of the change...or it could change the innerHTML (not sure why you''re doing this but ok) of the element.

It''s nice when encapsulation works for you :)

-Frinny


这篇关于ASP.NET进展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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