ASP.NET 事件存根未在 Visual Studio 中按预期创建 [英] ASP.NET event stub not created as expected in Visual Studio

查看:18
本文介绍了ASP.NET 事件存根未在 Visual Studio 中按预期创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个 ASP.NET Web 用户控件,其中包含几个其他控件.每当我尝试使用表单设计器将事件分配给控件时,Visual Studio 都会给出一个沙漏,然后添加事件处理程序存根.

I have written an ASP.NET web user control with several other controls in it. Whenever I try to assign an event to a control using the form designer, Visual Studio gives an hourglass for a moment, then does not add the event handler stub.

我可以手动添加事件处理程序代码并编辑 HTML 以将其绑定在一起,但有人知道可能导致这种行为的原因吗?

I can manually add the event handler code and edit the HTML to tie it together, but does anyone know what might cause this behavior?

我在 Win7 64 位上使用 Visual Studio 2008.

I'm using Visual Studio 2008 on Win7 64bit.

我遵循的步骤是:

1 - 右键单击​​复选框控件并选择属性"

1 - Right-click on a checkbox control and choose "Properties"

2 - 转到属性表的事件"区域(闪电)

2 - Go to the "events" area of the Properties sheet (the lightning bolt)

3 - 双击CheckedChanged"事件

3 - Double-click on the "CheckedChanged" event

结果:没有

我还应该注意到 CheckedChanged 事件的事件下拉列表是空的.

I should also note that the event drop down list for the CheckedChanged event is empty.

回应一些评论:

1 - 在我的 .ascx 文件中设置了代码隐藏"属性:

1 - The "codebehind" attribute is set in my .ascx file:

<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Filename.ascx.vb" Inherits="NameSpace.ClassName" %>

2 - 我重新启动了 Visual Studio 和我的电脑,结果相同.

2 - I have restarted Visual Studio and my pc with the same results.

推荐答案

我自己解决了这个问题.

I was able to fix this problem myself.

事实证明,我手动编辑了.designer.vb"文件以将其放在自定义命名空间中,但我没有对我的代码隐藏文件做同样的事情.

It turns out that I had manually edited the ".designer.vb" file to put it in a custom namespace, but I had not done the same thing to my code-behind file.

.designer.vb 文件实现了一个分部类,其中包含页面上所有控件的声明.

The .designer.vb file implements a partial class with declarations for all of the controls on the page.

代码隐藏文件完成了该分部类,但由于它们在技术上位于不同的命名空间中,.vb 文件没有看到分部类的其他部分".

The code-behind file completes that partial class, but since they were technically in different namespaces, the .vb file didn't see the other "part" of the partial class.

这篇关于ASP.NET 事件存根未在 Visual Studio 中按预期创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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