简体   繁体   English

从VB 2003(ASP.Net)迁移到C#2008 ASP.Net

[英]Migrating from VB 2003 (ASP.Net) to C# 2008 ASP.Net

I am converting an existing vb2003 asp.net 1.1 application to C#2008 asp.net 3.5. 我将现有的vb2003 asp.net 1.1应用程序转换为C#2008 asp.net 3.5。 I have copied the HTML onto my C# markup window (consisting of Labels, text fields & buttons) 我已将HTML复制到我的C#标记窗口中(由标签,文本字段和按钮组成)

However, when I attepmt to "View in browser", I get the error below: 但是,当我选择“在浏览器中查看”时,出现以下错误:

Compiler Error Message: CS1061: 'ASP.apps_forms_newproductregistration_newproductreg_aspx' does not contain a definition for 'btnSubmit_Click' and no extension method 'btnSubmit_Click' accepting a first argument of type 'ASP.apps_forms_newproductregistration_newproductreg_aspx' could be found (are you missing a using directive or an assembly reference?) 编译器错误消息:CS1061:'ASP.apps_forms_newproductregistration_newproductreg_aspx'不包含'btnSubmit_Click'的定义,并且没有扩展方法'btnSubmit_Click'接受类型为'ASP.apps_forms_newproductregistration_newproductreg_aspx'的第一个参数(可能是找不到(或者您缺少使用的)组装参考?)

Source Error: 来源错误:

Line 320:<tr>
Line 321:    <td><input type="reset" value="Reset" class="formbutton">
Line 322:    <asp:button cssclass="formbutton" text="Next" id="btnSubmit" runat="server" onclick="btnSubmit_Click"/></td>
Line 323:</tr>

My code behind contains the following code: 我后面的代码包含以下代码:

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (ValidateHeader() && ValidateFooter())
            LoadDatabase();

    }

Any ideas? 有任何想法吗?

I had some compatibility issues as well when I copied and pasted code from one version to another. 当我将代码从一个版本复制并粘贴到另一个版本时,我也遇到一些兼容性问题。 Your best bet would be to re-type the complete code from scratch. 最好的选择是从头开始重新输入完​​整的代码。

HTH. HTH。

After thinking about this for a few minutes, my first thought is this: 考虑了几分钟之后,我首先想到的是:

Something in the aspx file's @Page directive is wrong. aspx文件的@Page指令中有错误。 A Typical ASP.NET Page header for C# in VS2008 looks like this: VS2008中C#的典型ASP.NET Page标头如下所示:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

(That's from a new /Default.aspx file, your files may have additional attributes such as MasterPageFile) (这是来自新的/Default.aspx文件,您的文件可能具有其他属性,例如MasterPageFile)

Note that the Inherits line is case-sensitive in C#, so it should match the CodeFile's class name exactly. 请注意,继承行在C#中区分大小写,因此它应与CodeFile的类名完全匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM