首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

非静态的字段、方法或属性“System.Web.UI.WebControls.Label.Text.get”要求对象引用解决思路

2012-01-12 
非静态的字段、方法或属性“System.Web.UI.WebControls.Label.Text.get”要求对象引用运行提示为非静态的字段

非静态的字段、方法或属性“System.Web.UI.WebControls.Label.Text.get”要求对象引用
运行提示为
非静态的字段、方法或属性“System.Web.UI.WebControls.Label.Text.get”要求对象引用
代码如下:

C# code
using System;using System.Runtime.InteropServices;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Serialization;using Microsoft.SharePoint;using Microsoft.SharePoint.WebControls;using Microsoft.SharePoint.WebPartPages;using ActiveDs;using Velde;namespace WebPart1{    [Guid("0fcf1f6b-e232-4911-ae56-27158078c75d")]    public class WebPart1 : System.Web.UI.WebControls.WebParts.WebPart    {        public WebPart1()        {        }        protected override void CreateChildControls()        {            base.CreateChildControls();            // TODO: add custom rendering code here.            AD ad = new AD();            bool t5 = ad.createUserAccount("OU=te33fd,DC=BOM,DC=com", "wskty", "wskandwsk", "临", "时的", "2010-12-12");            Label label = new Label();            if (t5 == true)                Label.Text = "帐号为创建成功!";            else                Label.Text = "对不起,帐号未创建!";            //label.Text = "Hello World";            this.Controls.Add(label);        }    }}

请高手解决下

[解决办法]
写错了吧,把类和对象名搞混了,红色部分应该是label
Label label = new Label();
if (t5 == true)
Label.Text = "帐号为创建成功!";
else
Label.Text = "对不起,帐号未创建!";

[解决办法]
Label label1= new Label();
if (t5 == true)
label1.Text = "帐号为创建成功!";
else
label1.Text = "对不起,帐号未创建!";
取名字也取的清楚点的啊!现在弄的大小写都分不清楚

热点排行