VB WithEvents问题 [英] VB WithEvents issue

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

问题描述

大家好,



我一直在寻找答案,但我仍然难倒。



我在Visual Studio 2013中创建了一个aspx页面(名为default.aspx),使用DevExpress工具显示一个显示联系信息的AspxDataGridView。



我已经在default.aspx.vb文件中添加了代码,该文件检查用户是否已登录,并使用MultiView根据他们是否登录将其发送到不同的视图。

 Public Sub MultiView1_Init(ByVal sender As Object,ByVal e As System.EventArgs)处理MultiView1.Init 
'(登录if语句在这里)
End Sub

多视图的default.aspx.vb代码显示为:


在我的default.aspx.vb.designer文件中,我有以下行:

 Friend WithEvents MultiView1 As Global.System .Web.UI.WebControls.MultiView 

这非常有效 - 我可以加载页面,使用gridview附带的在线编辑来编辑数据 - 一切正常。



然后我创建了一个新页面(changelog.aspx)通过超链接列从现有gridview作为新页面(_blank)启动 - 这是使用数据库中的changelog表显示对记录所做更改的简单gridview。使用SQL和查询字符串填充新页面的
gridview。



但是,当我单击超链接时,新页面会打开但编译错误说明:
$


编译器错误消息:BC30506:Handles子句需要在包含类型或其基本类型中定义的WithEvents变量。



消息继续说明源错误位于以下行的default.aspx.vb文件中:

 Public Sub MultiView1_Init(ByVal sender As Object,ByVal e As System.EventArgs)处理MultiView1.Init 

由于某种原因,它已开始说我的多视图我的vb文件中的代码没有withevents行 - 但它确实如上所述,如果没有,我肯定无法在我的网页浏览器中加载default.aspx吗?



这开始让我头疼 - 加载新页面(changelog.aspx)是我需要工作的最后一件事,然后我的项目完成。



任何帮助都将被感激地收到。


 


Live Long and Prosper。

解决方案

Tom,


你自己写的。现有的新页面。现在你可能遇到了麻烦,因为你已经在该类中创建了init子句,因此它还不存在。 


然而,只是一个猜测,用ASP.Net重定向总是问题,不是因为技术问题,而是因为我们经常使用错误。


这个论坛不适用于UI问题(也不适用于Windows表单,但有些奇怪,总是会回答)。  ;


尝试解决您的问题Microsoft ASP.Net论坛


http://forums.asp.net


Hi Everyone,

I've been searching for an answer to this for a while but i'm still stumped.

I have created an aspx page in Visual Studio 2013 (called default.aspx) using DevExpress tools to show an AspxDataGridView which shows contact information.

I have added code to the default.aspx.vb file which checks if a user is logged in and, using a MultiView, sends them to a different view based on whether they are logged in or not.

Public Sub MultiView1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MultiView1.Init
        '(login if statement is here)
End Sub

My default.aspx.vb code for the multiview shows as:

In my default.aspx.vb.designer file I have the following line:

Friend WithEvents MultiView1 As Global.System.Web.UI.WebControls.MultiView

This worked perfectly - I could load the page, edit data using the in-line editing that comes with a gridview - all worked fine.

I then created a new page (changelog.aspx) which is launched as a new page (_blank) from the existing gridview via a hyperlink column - this is to display a simple gridview of changes made to the record using a changelog table in the database. The new page's gridview is populated using SQL and a query string.

However, when i click the hyperlink, the new page opens but with a compilation error stating:

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

The message goes on to say the source error is in my default.aspx.vb file on the following line:

Public Sub MultiView1_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles MultiView1.Init

For some reason it has started saying my multiview code in my vb file doesn't have a withevents line - but it does, as above, and if it didnt, i wouldnt be able to load default.aspx in my web browser surely?

This is starting to give me a headache - loading the new page (changelog.aspx) is the last thing I need to get working then my project is done.

Any help would be gratefully recieved.

 

Live Long and Prosper.

解决方案

Tom,

Your wrote it yourself. New page from the existing one. Now you're probably in trouble because you have created the init clause inside that class so it does not exist yet. 

However, just a guess, redirecting with ASP.Net has always issues, not because of the technique, but just we often use it wrong.

This forum is not for UI questions (also not for Windows forms but strange enough those are always answered). 

Try for your problem the Microsoft ASP.Net forum

http://forums.asp.net


这篇关于VB WithEvents问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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