控件添加Attributes问题.

遊戲王千金 2011-01-05 10:55:24
如题,给网页一个lable控件,添加如下代码,出现< 被编码,如何解决。。
后台代码
lbl.Attributes["onmouseover"] =
"if ( this.clientWidth < this.scrollWidth ) this.title = this.innerText; else this.title = '';";

前台查看源代码。
<span id="lbl" onmouseover="if ( this.clientWidth < this.scrollWidth ) this.title = this.innerText; else this.title = '';" >测试Attributes</span>
用红色标出问题所在
...全文
112 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
遊戲王千金 2011-01-05
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 sp1234 的回复:]
以测试为准,只要javascript执行没有问题,就不要管它。
[/Quote]
6楼正解。弄糊涂了特殊符号不用理,只有换行需要
在js里\r\n,在string里转行才需要\\r\\n
  • 打赏
  • 举报
回复
以测试为准,只要javascript执行没有问题,就不要管它。
  • 打赏
  • 举报
回复
[Quote=引用楼主 learnjsee 的回复:]
如题,给网页一个lable控件,添加如下代码,出现< 被编码,如何解决。。
后台代码
lbl.Attributes["onmouseover"] =
"if ( this.clientWidth < this.scrollWidth ) this.title = this.innerText; else this.title = '';";

前台查看源代码。
<span id="……
[/Quote]

这很正确啊?!

你了解一下html。html element的属性中的特殊符号,当然可以编码的。
TimZhuFaith 2011-01-05
  • 打赏
  • 举报
回复
不如把那句 写成方法调用。。
moudy 2011-01-05
  • 打赏
  • 举报
回复


lbl.Attributes["onmouseover"] =
"if ( this.clientWidth \< this.scrollWidth ) this.title = this.innerText; else this.title = '';";
zhubo_1117 2011-01-05
  • 打赏
  • 举报
回复
>被转义了
jin225 2011-01-05
  • 打赏
  • 举报
回复
lbl.Attributes["onmouseover"] =
"if ( this.clientWidth <this.scrollWidth ) this.title = this.innerText; else this.title = '';";

这样你看看

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧