读书人

C#web开发cs资料无法操作页面的asp标签

发布时间: 2012-09-12 09:21:30 作者: rapoo

C#web开发cs文件无法操作页面的asp标签
是这样的,项目的login.aspx页面中本来没事,后来添加了个验证码框
<asp:TextBox ID="checkbox" runat="server">,
结果login.aspx.cs中调用this.checkbox时,系统报错:

'login' does not contain a definition for 'checkbox' and no extension method 'checkbox' accepting a first argument of type 'login' could be found (are you missing a using directive or an assembly reference?)

后来就发现好多前台的asp标签都不能识别了
后来没办法,我就把loing.aspx删了,重新建了一个空的文件来测试

C# code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">  <title></title></head><body>  <form id="form1" runat="server">  <div>  <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:TextBox ID="TextBox1"  runat="server"></asp:TextBox>      </div>  </form></body></html>


发现还是在cs文件中还是不能操作标签Label1,和TextBox1,就是用this.后系统不提示Label1
Error1'login' does not contain a definition for 'Label1' and no extension method 'Label1' accepting a first argument of type 'login' could be found (are you missing a using directive or an assembly reference?)E:\VsWebsite\Spjk\login.aspx.cs1914E:\VsWebsite\Spjk\
请问这是为什么啊

[解决办法]
我这里没有这个问题,和你的代码完全一样
HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title></head><body>    <form id="form1" runat="server">    <div>     <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><asp:TextBox ID="TextBox1"  runat="server"></asp:TextBox>    </div>    </form></body></html>
[解决办法]
我刚刚也是发生了这种情况 你是不是 删除了 又重建了的?
[解决办法]
建议删除重新建立,以前开发遇到多次 都是这样的。。因为 找原因要很久

读书人网 >asp.net

热点推荐