html隐式类型转换,CS0029:不能将类型'字符串'隐式转换为'System.Web.UI.HtmlControls.HtmlGenericControl'(CS0029: Cannot impl...

CS0029:不能将类型'字符串'隐式转换为'System.Web.UI.HtmlControls.HtmlGenericControl'(CS0029: Cannot implicitly convert type 'string' to 'System.Web.UI.HtmlControls.HtmlGenericControl')

使用asp.net webforms我收到第1行的这个错误:

CS0029:不能将类型'字符串'隐式转换为'System.Web.UI.HtmlControls.HtmlGenericControl'

Evaluations

Using asp.net webforms I receive this error on line 1:

CS0029: Cannot implicitly convert type 'string' to 'System.Web.UI.HtmlControls.HtmlGenericControl'

Evaluations

原文:https://stackoverflow.com/questions/50277520

更新时间:2020-01-07 18:07

最满意答案

runat="server"不能有ID="Title" runat="server" 。

将ID更改为其他任何内容,如Title1或PageTitle,并且页面编译并再次正常运行。

Evaluations

至:

Evaluations

解决问题。

此问题是由于生成的部分类隐藏控件上的现有标题而引起的。

You can't have ID="Title" with runat="server".

Changing the ID to anything else, like Title1 or PageTitle, and the page compiles and runs fine again.

Evaluations

To:

Evaluations

Fixes the problem.

This problem is caused because the partial class that gets generated hides the existing Title on the control.

相关问答

runat="server"不能有ID="Title" runat="server" 。 将ID更改为其他任何内容,如Title1或PageTitle,并且页面编译并再次正常运行。

Evaluations

至:

Evaluations

解决问题。 此问题是由于生

...

private BMS2Entities _db = new BMS2Entities ();

public string getActTypes()

{

return (_db.tblOpenActs.Select(a => a.actType)).FirstOrDefault();

}

private BMS2Entities _db = new BMS2Entities ();

public string getActTypes()

{

return (_db.tblO

...

尝试这个: lblTimeAllotted.text = row.Cells[4].Text;

lblPosterName.text = row.Cells[5].Text;

你不能为文本设置标签。 您需要设置标签的text属性 Try this: lblTimeAllotted.text = row.Cells[4].Text;

lblPosterName.text = row.Cells[5].Text;

You cant set a label to a text. You need t

...

score = PlayerPrefs.GetInt ("score");

错误是由上面的行引起的。 PlayerPrefs.GetInt因为它的名称状态将返回一个整数。 现在看看你如何声明score变量: Score score;

这会导致变量score具有类型Score类,而不是int 。 我想你想在Score类中设置变量score 。 由于您将变量score声明为static public ,这使事情变得简单。 您不必创建Score的实例,只需使用类名Score (以大写字母S)代替:

...

如果错误提示cannot implicitly convert type "System.Collections.IList" to "System.Collection.ArrayList" ,那么可能cannot implicitly convert type "System.Collections.IList" to "System.Collection.ArrayList"一个IList变量分配给一个ArrayList变量。 请注意, IList是一个比具体类型ArrayList更通用的接

...

你可以使用Color.FromName()将字符串转换为Color。 例 label15.BackColor = Color.FromName(colours(res[0] - '0'));

请注意,您没有在其他语句后面,只有第一行在其他语句中执行,其他行将始终执行。 你不必,但我建议你这样做 if (res.Count() > 11)

{

MessageBox.Show("Invalid value");

}

else

{

textBox4.Text = ..

tex

...

我们最终使用'HTMLGenericControl()'并将web.config targetFramework更改为4.0而不是4.6.1。

这允许我们在使用现有的“HTMLGenericControl()”代码时在Web项目中使用.Net framework 4.6.1编译库。 We ended up using 'HTMLGenericControl()' and change web.con

...

改变这个: file.Tag.Title = new string[] {txtTitle.Text};

至: file.Tag.Title = txtTitle.Text;

Title类型是string ,而不是string[]数组(不是string[] ),但是您尝试分配数组 - 因为它会导致错误。 其他字段的类型为string[] (字符串数组),这就是为什么只有Title才会出错。 此外,您尝试将值分配给Title 2次: if (!string.IsNullOrWhiteSpace(

...

因为IComparer必须提供一种方法 int Compare(T x, T y)

即,它必须返回一个int ,而不是一个bool 。 如果a > b它必须返回一个int > 0 。 如果a = b它必须返回0 。 如果a < b它必须返回一个int < 0 。 你的第二个例子使用a.CompareTo(b) ,它确实返回了所需的int 。 如果要实现自己的逻辑,可以将lambda写为: (a, b) => a > b ? +1 : a < b ? -1 : 0

Beacuse an I

...

尝试 dyqan.Shitesit.Add(new Shites { Emeri = "Kujtim", Mbiemeri = "Arishta" });

dyqan.Shitesit.Add(new Shites { Emeri = "Zaim", Mbiemeri = "Sherbela" });

dyqan.Produkte.Add(new Produkt {Lloji = "Dap",Kilogram =25M,Cmimi=2.500M});

...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值