ASP.NET 事件存根未按 Visual Studio 中的预期创建
我编写了一个 ASP.NET Web 用户控件,其中包含其他几个控件。每当我尝试使用表单设计器将事件分配给控件时,Visual Studio 会出现一段时间的沙漏,然后不添加事件处理程序存根。
我可以手动添加事件处理程序代码并编辑 HTML 将其绑定在一起,但有人知道什么可能会导致此行为吗?
我在 Win7 64 位上使用 Visual Studio 2008。
我遵循的步骤是:
1 - 右键单击复选框控件并选择“属性”
2 - 转到属性表的“事件”区域(闪电)
3 - 双击“CheckedChanged”事件
结果:没什么
我还应该注意的是,CheckedChanged 事件的事件下拉列表是空的。
回应一些评论:
1 - 在我的 .ascx 文件中设置“代码隐藏”属性:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Filename.ascx.vb" Inherits="NameSpace.ClassName" %>
2 - 我重新启动了 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.
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?
I'm using Visual Studio 2008 on Win7 64bit.
The steps I follow are:
1 - Right-click on a checkbox control and choose "Properties"
2 - Go to the "events" area of the Properties sheet (the lightning bolt)
3 - Double-click on the "CheckedChanged" event
Result: Nothing
I should also note that the event drop down list for the CheckedChanged event is empty.
In response to some of the comments:
1 - The "codebehind" attribute is set in my .ascx file:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Filename.ascx.vb" Inherits="NameSpace.ClassName" %>
2 - I have restarted Visual Studio and my pc with the same results.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了这个问题。
事实证明,我手动编辑了“.designer.vb”文件以将其放入自定义命名空间中,但我没有对我的代码隐藏文件执行相同的操作。
.designer.vb 文件实现了一个分部类,其中包含页面上所有控件的声明。
代码隐藏文件完成了该分部类,但由于它们在技术上位于不同的命名空间中,因此 .vb 文件没有看到分部类的其他“部分”。
I was able to fix this problem myself.
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.
The .designer.vb file implements a partial class with declarations for all of the controls on the page.
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.