无法将字符串隐式转换为System.Web.UI.WebControls.TextBox [英] Cannot implicitly convert string to 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 thattxtWhatOnYourHeart
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屋!