无法将字符串隐式转换为System.Web.UI.WebControls.TextBox [英] Cannot implicitly convert string to System.Web.UI.WebControls.TextBox

查看:260
本文介绍了无法将字符串隐式转换为System.Web.UI.WebControls.TextBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试清空一个文本框..当我编译我的代码时..给出一个错误说不能隐式地将字符串转换为System.web.UI.Webcontrols.Textbox。

LatestUpdate。 ascx代码

< panel runat =serverid =pnlStatur>

< asp:TextBox ID =txtWhatsOnYourHeartrunat =server>



代码背后

LatestUpdates.ascx.cs

protected void btnPost_Click(Object sender,EventArgs e)

{LatestUpdate();

txtWhatOnYourHeart = Empty.string; }

I am trying to empty a textbox..when i compile my code..it give an error say Can not implicitly convert string to System.web.UI.Webcontrols.Textbox.
LatestUpdate.ascx code
<panel runat="server" id="pnlStatur">
<asp:TextBox ID="txtWhatsOnYourHeart" runat="server">

Code Behind
LatestUpdates.ascx.cs
protected void btnPost_Click(Object sender, EventArgs e)
{LatestUpdate();
txtWhatOnYourHeart=Empty.string; }

推荐答案

可能你的意思是 txtWhatOnYourHeart 是你要清理的文本框。但是这不是字符串,这是一个文本框,与字符串无关的类型; txtWhatOnYourHeart.Text 是字符串。



-SA
Probably you mean that txtWhatOnYourHeart is the text box you want to clean. But then this is not string, this is a text box, a type unrelated to string; txtWhatOnYourHeart.Text is string.

—SA


这篇关于无法将字符串隐式转换为System.Web.UI.WebControls.TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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