注册 登录
编程论坛 ASP.NET技术论坛

初用VS 2005遇到的问题 for C#

ccsky 发布于 2007-03-14 11:04, 612 次点击
以前经常使用 VS 2003 现在改为了VS 2005 用了2005后一点点问题


if (this.tbContent.Text != null ) // 这个“ != null”有点问题
{
this.lblHello = this.tbContent.Text.Trim() + ",你好!";
}
else
{
this.lblHello.Text = "姓名不能为空!";
}

以上这段报错,请教 怎么解决。
7 回复
#2
cyyu_ryh2007-03-14 12:38
if (this.tbContent.Text != "")
因该是字符
#3
bygg2007-03-14 13:02
if (this.tbContent.Text.Trim() != "" )
#4
ccsky2007-03-14 13:32
以下是引用cyyu_ryh在2007-3-14 12:38:39的发言:
if (this.tbContent.Text != "")
因该是字符

以下是引用bygg在2007-3-14 13:02:14的发言:
if (this.tbContent.Text.Trim() != "" )

这个依然报错

#5
cyyu_ryh2007-03-14 13:38

不可能哦,依然是那里报错?
#6
ccsky2007-03-14 13:57
this.lblHello = this.tbContent.Text.Trim() + ",你好!";

错误 1 无法将类型“string”隐式转换为“System.Web.UI.WebControls.Label” C:\My Documents\Visual Studio 2005\WebSites\WebSite2\Default.aspx.cs 22 29 C:\...\WebSite2\
#7
ccsky2007-03-14 14:01

啊~ 对不起各位了~`
this.lblHello = this.tbContent.Text.Trim() + ",你好!";
这句this.lblHello的后面忘记加Text了 真是不好意思

#8
小恶魔2007-03-14 20:28

我看了前面3贴也很郁闷,最后(上面)这一贴我才看出来,林子大了什么人(鸟)都有!
虽然发了水贴 但我还是得笑一下!!!

1