ASPX和aspx.cs文件之间的链接断开 [英] Broken link between aspx and aspx.cs files

查看:200
本文介绍了ASPX和aspx.cs文件之间的链接断开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有同样的问题,几个不同的ASPX页面时间对其进行重命名后,我很惊讶,我不能找别人与计算器同样的问题。

I've had the same problem a couple of times with different ASPX pages after renaming them and I am surprised that I can't find someone else with the same problem on stackoverflow.

当我运行我的ASP.NET C#项目,调试器给了我这样一个消息。

When I run my ASP.NET C# project, the debugger gives me a message like this one.

Error   5   The name 'txtTitle' does not exist in the current context

看来,ASPX和aspx.cs文件时不再绑定。我发现这样做的唯一的解决方法是重新创建的页面和复制/粘贴我的code。

It seems that the aspx and aspx.cs files at no longer bound. The only fix I have found for this is to recreate the page and copy/paste my code.

不知道如何解决这一问题而无需重新创建整个事情?

Any idea how to fix this without recreating the whole thing?

感谢

推荐答案

在code文件包含在ASPX头声明中引用的部分类。这两个文件的名称,并在ASPX头实际的类必须匹配这个工作。

The code file contains a partial class that is referenced in the ASPX header declaration. Both file name and the actual class in the ASPX header have to match for this to work.

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

在你的情况可能是类名不匹配。检查在codebehind cs文件的类名后的名称相匹配的继承

In your case probably the class name does not match. Check if the class name in the codebehind .cs file matches the name after Inherits.

在ASP.NET中使用部分类的概念是详细这里

The concept of partial classes used in ASP.NET is detailed here.

这篇关于ASPX和aspx.cs文件之间的链接断开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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