1

我一直在尝试在直到最近一直正常工作的页面上解决此错误。我想知道是否有人可以帮助我确定此错误的原因,因为我已尽我所能修复它,但没有成功。

错误信息:

错误 27 无法使用“VB”,因为本页前面已指定另一种语言(或从 CodeFile 属性中隐含)。W:\admin.fctl.ucf.edu\inventory\old\address.ascx 2

我的代码:

<%@ Control CodeBehind="address.ascx.cs" Language="c#" AutoEventWireup="false" Inherits="Inventory1.address" %>
<Script language="VB" runat="Server">

        Public Property Address1 as string
            Get
                Return txtAddress1.text
            End Get
            Set
                txtAddress1.text = value
            End Set     
        End property

        Public Property Address2 as string
            Get
                Return txtAddress2.text
            End Get
            Set
                txtAddress2.text = value
            End Set 
        End property

        Public Property city as string
            Get
                Return txtcity.text
            End Get
            Set
                txtcity.text = value
            End Set     
        End property

        Public Property state as string
            Get
                Return cbostate.selecteditem.text
            End Get
            Set
                cbostate.selectedindex = value
            End Set     
        End property

        Public Property zip as string
            Get
                Return txtzip.text
            End Get
            Set
                txtzip.text = value
            End Set 
        End property

        Public Property country as string
            Get
                Return cbocountry.selecteditem.text
            End Get
            Set
                cbocountry.selectedindex = value
            End Set     
        End property

        Public Property phone1 as string
            Get
                Return txtphone1.text
            End Get
            Set
                txtphone1.text = value
            End Set     
        End property

        Public Property phone2 as string
            Get
                Return txtphone2.text
            End Get
            Set
                txtphone2.text = value
            End Set     
        End property

        Public Property mobile as string
            Get
                Return txtmobile.text
            End Get
            Set
                txtmobile.text = value
            End Set     
        End property

        Public Property email as string
            Get
                Return txtemail.text
            End Get
            Set
                txtemail.text = value
            End Set     
        End property

        Public Property fax as string
            Get
                Return txtfax.text
            End Get
            Set
                txtfax.text = value
            End Set     
        End property

        Public Property pager as string
            Get
                Return txtpager.text
            End Get
            Set
                txtpager.text = value
            End Set     
        End property
</Script>
4

2 回答 2

5

您的代码在 C# 中:

<%@ Control CodeBehind="address.ascx.cs" Language="c#" 

Because of that, you can only embed C# code into the page, not VB code. Either use entirely VB for both the code behind and the embedded scriptlets, or use entirely C# in both cases.

于 2013-02-27T17:20:29.370 回答
0

使用以下链接将 vb.net 转换为 C#,然后您不必担心

VB 到 C# 转换器

或者:

你为什么不把你的VB代码编译成一个库(.dll)。稍后从你的代码中引用它,就是这样。托管 dll 包含 C# 和 vb 都编译到的 MSIL

于 2013-02-27T17:20:26.507 回答