无法创建事件处理程序 [英] Failure to create event handler

查看:61
本文介绍了无法创建事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个非常简单的网页(ASP.NET)。在

网页上有一个复选框,可根据

检查状态启用或禁用其他控件。但是,.NET无法为

CheckedChanged事件创建事件处理程序。


此外,即使我手动创建事件处理程序,CheckedChanged

事件永远不会在运行时执行。 AutoPostBack设置为True。有时,

..NET丢失我辛苦创建的代码块。


而且,为了增加我的乐趣,IDE始终如一地笨拙。在我身上 -

保留字在编辑过程中失去了突出显示和

IntelliSense拒绝显示对象的事件和方法列表。

我正在使用带有ASP.NET和C#的Visual Studio .NET 2003 Enterprise Architect。

Microsoft Development Environment 2003版本7.1.3088和Microsoft .NET

框架版本1.1.4322 SP1

我的PC(Dell OptiPlex GX280,512MB RAM)正在运行Win2K Pro(版本5,
Build 2195,SP4)。


我必须承认我对这个产品非常沮丧 - IDE有点儿错误

就像地狱一样。如果我的公司没有坚持使用.NET,我会切换回

VFP并一劳永逸地完成这个废话。


任何提供的帮助都非常感谢。


-RW-

I have a very simple web page (ASP.NET) that I am trying to build. On the
web page is a checkbox that enables or disables other controls based upon the
checked status. However, .NET fails to create the event handler for the
CheckedChanged event.

In addition, even if I manually create the event handler, the CheckedChanged
event is never executed at runtime. AutoPostBack is set to True. Sometimes,
..NET "loses" blocks of code that I have painstakingly created.

And, just to add to my fun, the IDE consistently goes "whacky" on me -
reserved words lose their highlighting in the middle of editing and
IntelliSense refuses to display lists of the events and methods for objects.

I am using Visual Studio .NET 2003 Enterprise Architect with ASP.NET and C#.
Microsoft Development Environment 2003 Version 7.1.3088 and Microsoft .NET
Framework Version 1.1.4322 SP1

My PC (Dell OptiPlex GX280, 512MB RAM) is running Win2K Pro (Version 5,
Build 2195, SP4).

I must admit that I am VERY frustrated with this product - the IDE is buggy
as hell. If my company didn''t insist upon using .NET, I would switch back to
VFP and be done with this nonsense once and for all.

Any help that is offered is *greatly* appreciated.

-RW-

推荐答案

Richard,


每个人都可以向我们展示你的代码,我们可以帮助你找出为什么从未执行

事件处理程序。可能是

情况的一个主要原因是,事件处理程序未在控件中注册。如果您使用IDE从页面中删除控件,则会发生这种情况。所以,如果您的事件

处理程序看起来像这样

private void MyHandler(对象发送者,EventArgs e)

{

}


检查一行如下:


myControl.Load + = new EventHandler(MyHandler);


几乎在所有情况下我都看到事件处理程序没有触发,上面一行的缺席是原因。造成这种情况的原因是,当您从页面中删除控件时(在IDE中),IDE还会删除该控件的所有

注册事件处理程序。 br />

希望有所帮助!


-

Manohar Kamath

编辑,。 netBooks
www.dotnetbooks.com

" Richard W" <日****** @ discussions.microsoft.com>在消息中写道

新闻:FE ********************************** @ microsof t.com ...
Richard,

Per haps you can show us your code, and we could help you figure out why the
event handler was never executed. The one major reason why it might be the
case is, the event handler was not registered with the control. This happens
if you remove the control from the page, using the IDE. So, if your event
handler looks like this

private void MyHandler(object sender, EventArgs e)
{
}

check for a line something like:

myControl.Load+= new EventHandler(MyHandler);

In almost all cases I have seen the event handlers not firing, the absence
of the above line has been the cause. The cause for this cause, is when you
remove a control from the page (in IDE), the IDE also removes all the
registered event handlers for that control.

Hope that helps!

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"Richard W" <Ri******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
我有一个非常简单的网页(ASP.NET),我正在尝试构建。在
网页上有一个复选框,可根据
检查状态启用或禁用其他控件。但是,.NET无法为
CheckedChanged事件创建事件处理程序。

此外,即使我手动创建事件处理程序,
CheckedChanged
事件永远不会在运行时执行。 AutoPostBack设置为True。
有时,
.NET丢失我辛苦创建的代码块。

而且,为了增加我的乐趣,IDE始终如一地笨拙。在我身上 -
保留字在编辑过程中失去了突出显示,并且IntelliSense拒绝显示对象的事件和方法列表。

我正在使用带有ASP.NET和/或C#的Visual Studio .NET 2003企业架构师。
Microsoft开发环境2003版本7.1.3088和Microsoft .NET
框架版本1.1.4322 SP1

我必须承认我对此产品非常沮丧 - IDE很糟糕
如同地狱。如果我的公司没有坚持使用.NET,我会转回
到VFP并一劳永逸地完成这个废话。

任何帮助都是提供*非常*赞赏。

-RW -
I have a very simple web page (ASP.NET) that I am trying to build. On the
web page is a checkbox that enables or disables other controls based upon
the
checked status. However, .NET fails to create the event handler for the
CheckedChanged event.

In addition, even if I manually create the event handler, the
CheckedChanged
event is never executed at runtime. AutoPostBack is set to True.
Sometimes,
.NET "loses" blocks of code that I have painstakingly created.

And, just to add to my fun, the IDE consistently goes "whacky" on me -
reserved words lose their highlighting in the middle of editing and
IntelliSense refuses to display lists of the events and methods for
objects.

I am using Visual Studio .NET 2003 Enterprise Architect with ASP.NET and
C#.
Microsoft Development Environment 2003 Version 7.1.3088 and Microsoft .NET
Framework Version 1.1.4322 SP1

My PC (Dell OptiPlex GX280, 512MB RAM) is running Win2K Pro (Version 5,
Build 2195, SP4).

I must admit that I am VERY frustrated with this product - the IDE is
buggy
as hell. If my company didn''t insist upon using .NET, I would switch back
to
VFP and be done with this nonsense once and for all.

Any help that is offered is *greatly* appreciated.

-RW-



Manohar,


感谢您的快速回复!这是我正在使用的代码:
Manohar,

Thanks for the speedy reply! Here is the code I am using:
这是在InitializeComponent()


this.CheckBox1 .CheckedChanged + = new EventHandler(CheckBox1_CheckedChanged)


这是*单击CheckBox时*应该*触发的代码
This is in the InitializeComponent()
this.CheckBox1.CheckedChanged += new EventHandler(CheckBox1_CheckedChanged)

This is the code that *should* fire when the CheckBox is clicked



private void CheckBox1_CheckedChanged (对象发送者,System.EventArgs e)

{

Debug.WriteLine(" Checkbox1已被更改......);

}


此代码永远不会触发。


-RW-

" Manohar Kamath"写道:

Richard,

你可以向我们展示你的代码,我们可以帮你找出为什么从未执行过
事件处理程序。可能是
情况的一个主要原因是,事件处理程序未在控件中注册。如果您使用IDE从页面中删除控件,则会发生这种情况。所以,如果您的事件处理器看起来像这样

private void MyHandler(对象发送者,EventArgs e)
{
}

检查对于一行如下:

myControl.Load + = new EventHandler(MyHandler);

几乎在所有情况下我都看到事件处理程序没有触发,缺席
以上一直是原因。造成这种情况的原因是,当您从页面中删除控件时(在IDE中),IDE还会删除该控件的所有已注册的事件处理程序。

希望这有帮助!

-
Manohar Kamath
编辑,.netBooks
www.dotnetbooks.com

" Richard W" <日****** @ discussions.microsoft.com>在消息中写道
新闻:FE ********************************** @ microsof t.com。 ..


private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
Debug.WriteLine("Checkbox1 was changed...");
}

This code never fires.

-RW-
"Manohar Kamath" wrote:
Richard,

Per haps you can show us your code, and we could help you figure out why the
event handler was never executed. The one major reason why it might be the
case is, the event handler was not registered with the control. This happens
if you remove the control from the page, using the IDE. So, if your event
handler looks like this

private void MyHandler(object sender, EventArgs e)
{
}

check for a line something like:

myControl.Load+= new EventHandler(MyHandler);

In almost all cases I have seen the event handlers not firing, the absence
of the above line has been the cause. The cause for this cause, is when you
remove a control from the page (in IDE), the IDE also removes all the
registered event handlers for that control.

Hope that helps!

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"Richard W" <Ri******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...

我有一个非常简单的网页(ASP.NET),我正在尝试构建。在
网页上有一个复选框,可根据
检查状态启用或禁用其他控件。但是,.NET无法为
CheckedChanged事件创建事件处理程序。

此外,即使我手动创建事件处理程序,
CheckedChanged
事件永远不会在运行时执行。 AutoPostBack设置为True。
有时,
.NET丢失我辛苦创建的代码块。

而且,为了增加我的乐趣,IDE始终如一地笨拙。在我身上 -
保留字在编辑过程中失去了突出显示,并且IntelliSense拒绝显示对象的事件和方法列表。

我正在使用带有ASP.NET和/或C#的Visual Studio .NET 2003企业架构师。
Microsoft开发环境2003版本7.1.3088和Microsoft .NET
框架版本1.1.4322 SP1

我必须承认我对此产品非常沮丧 - IDE很糟糕
如同地狱。如果我的公司没有坚持使用.NET,我会转回
到VFP并一劳永逸地完成这个废话。

任何帮助都是提供*非常*赞赏。

-RW -
I have a very simple web page (ASP.NET) that I am trying to build. On the
web page is a checkbox that enables or disables other controls based upon
the
checked status. However, .NET fails to create the event handler for the
CheckedChanged event.

In addition, even if I manually create the event handler, the
CheckedChanged
event is never executed at runtime. AutoPostBack is set to True.
Sometimes,
.NET "loses" blocks of code that I have painstakingly created.

And, just to add to my fun, the IDE consistently goes "whacky" on me -
reserved words lose their highlighting in the middle of editing and
IntelliSense refuses to display lists of the events and methods for
objects.

I am using Visual Studio .NET 2003 Enterprise Architect with ASP.NET and
C#.
Microsoft Development Environment 2003 Version 7.1.3088 and Microsoft .NET
Framework Version 1.1.4322 SP1

My PC (Dell OptiPlex GX280, 512MB RAM) is running Win2K Pro (Version 5,
Build 2195, SP4).

I must admit that I am VERY frustrated with this product - the IDE is
buggy
as hell. If my company didn''t insist upon using .NET, I would switch back
to
VFP and be done with this nonsense once and for all.

Any help that is offered is *greatly* appreciated.

-RW-




Manohar,

感谢您的快速回复!这是我正在使用的代码:
Manohar,

Thanks for the speedy reply! Here is the code I am using:
这是在InitializeComponent()


this.CheckBox1 .CheckedChanged + = new EventHandler(CheckBox1_CheckedChanged)


这是*单击CheckBox时*应该*触发的代码
This is in the InitializeComponent()
this.CheckBox1.CheckedChanged += new EventHandler(CheckBox1_CheckedChanged)

This is the code that *should* fire when the CheckBox is clicked



private void CheckBox1_CheckedChanged (对象发送者,System.EventArgs e)

{

Debug.WriteLine(" Checkbox1已被更改......);

}


此代码永远不会触发。


-RW-

" Manohar Kamath"写道:

Richard,

你可以向我们展示你的代码,我们可以帮你找出为什么从未执行过
事件处理程序。可能是
情况的一个主要原因是,事件处理程序未在控件中注册。如果您使用IDE从页面中删除控件,则会发生这种情况。所以,如果您的事件处理器看起来像这样

private void MyHandler(对象发送者,EventArgs e)
{
}

检查对于一行如下:

myControl.Load + = new EventHandler(MyHandler);

几乎在所有情况下我都看到事件处理程序没有触发,缺席
以上一直是原因。造成这种情况的原因是,当您从页面中删除控件时(在IDE中),IDE还会删除该控件的所有已注册的事件处理程序。

希望这有帮助!

-
Manohar Kamath
编辑,.netBooks
www.dotnetbooks.com

" Richard W" <日****** @ discussions.microsoft.com>在消息中写道
新闻:FE ********************************** @ microsof t.com。 ..


private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
Debug.WriteLine("Checkbox1 was changed...");
}

This code never fires.

-RW-
"Manohar Kamath" wrote:
Richard,

Per haps you can show us your code, and we could help you figure out why the
event handler was never executed. The one major reason why it might be the
case is, the event handler was not registered with the control. This happens
if you remove the control from the page, using the IDE. So, if your event
handler looks like this

private void MyHandler(object sender, EventArgs e)
{
}

check for a line something like:

myControl.Load+= new EventHandler(MyHandler);

In almost all cases I have seen the event handlers not firing, the absence
of the above line has been the cause. The cause for this cause, is when you
remove a control from the page (in IDE), the IDE also removes all the
registered event handlers for that control.

Hope that helps!

--
Manohar Kamath
Editor, .netBooks
www.dotnetbooks.com
"Richard W" <Ri******@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...

我有一个非常简单的网页(ASP.NET),我正在尝试构建。在
网页上有一个复选框,可根据
检查状态启用或禁用其他控件。但是,.NET无法为
CheckedChanged事件创建事件处理程序。

此外,即使我手动创建事件处理程序,
CheckedChanged
事件永远不会在运行时执行。 AutoPostBack设置为True。
有时,
.NET丢失我辛苦创建的代码块。

而且,为了增加我的乐趣,IDE始终如一地笨拙。在我身上 -
保留字在编辑过程中失去了突出显示,并且IntelliSense拒绝显示对象的事件和方法列表。

我正在使用带有ASP.NET和/或C#的Visual Studio .NET 2003企业架构师。
Microsoft开发环境2003版本7.1.3088和Microsoft .NET
框架版本1.1.4322 SP1

我必须承认我对此产品非常沮丧 - IDE很糟糕
如同地狱。如果我的公司没有坚持使用.NET,我会转回
到VFP并一劳永逸地完成这个废话。

任何帮助都是提供*非常*赞赏。

-RW -
I have a very simple web page (ASP.NET) that I am trying to build. On the
web page is a checkbox that enables or disables other controls based upon
the
checked status. However, .NET fails to create the event handler for the
CheckedChanged event.

In addition, even if I manually create the event handler, the
CheckedChanged
event is never executed at runtime. AutoPostBack is set to True.
Sometimes,
.NET "loses" blocks of code that I have painstakingly created.

And, just to add to my fun, the IDE consistently goes "whacky" on me -
reserved words lose their highlighting in the middle of editing and
IntelliSense refuses to display lists of the events and methods for
objects.

I am using Visual Studio .NET 2003 Enterprise Architect with ASP.NET and
C#.
Microsoft Development Environment 2003 Version 7.1.3088 and Microsoft .NET
Framework Version 1.1.4322 SP1

My PC (Dell OptiPlex GX280, 512MB RAM) is running Win2K Pro (Version 5,
Build 2195, SP4).

I must admit that I am VERY frustrated with this product - the IDE is
buggy
as hell. If my company didn''t insist upon using .NET, I would switch back
to
VFP and be done with this nonsense once and for all.

Any help that is offered is *greatly* appreciated.

-RW-




这篇关于无法创建事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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