ASP.NET控件在codeBehind不可用 [英] ASP.NET Control not available in CodeBehind

查看:173
本文介绍了ASP.NET控件在codeBehind不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拖上我ABC.ASPX page.It编译正确滴Label控件。
但控制( Label2的)是不是在code-背后ABC.ASPX.cs可供赋值。

什么是分辨率?

 <%@页语言=C#codeBehind =ABC.aspx.csAutoEventWireup =false的%GT; < ASP:标签ID =Label2的=服务器FONT-粗体=真>< / ASP:标签>


解决方案

你可能缺少的designer.cs文件中的条目。您可以像这样的东西添加到文件:

 保护全球:: System.Web.UI.WebControls.Label Label2的;

或删除designer.cs文件,右键单击父aspx文件,并选择转换为Web应用程序。这应该重新创建designer.cs与所有适当的条目文件。

I drag and drop a Label control on my ABC.ASPX page.It Compiles correctly. But the control (Label2) is not available in code-behind ABC.ASPX.cs for value assignment.

What is the resolution?

<%@ Page language="c#" CodeBehind="ABC.aspx.cs" AutoEventWireup="false" %> 

 <asp:Label ID="Label2" runat="server" Font-Bold="True"></asp:Label>

解决方案

You are probably missing an entry for this in your designer.cs file. You can either add something like this to the file:

protected global::System.Web.UI.WebControls.Label Label2;

Or delete the designer.cs file, right click the parent aspx file and choose "Convert to Web Application". This should recreate the designer.cs file with all the appropriate entries.

这篇关于ASP.NET控件在codeBehind不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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