我正在一个 asp.net 网站(web 表单和 mvc)上工作,其中 asp:Literal 在几个页面中使用。我需要更改一页的内容以向现有标签添加一个简单的标题属性。
所以我需要渲染的结果是:
<a href="test.jpg"
title="title here"
id="testimage"
rel="hint-text: CLICK TO ZOOM"
style="position: relative; display: inline-block">image goes here</a>
但是渲染之后是这样的:
<a href="test.jpg"
title id="testimage"
rel="hint-text: CLICK TO ZOOM"
style="position: relative; display: inline-block">image goes here</a>
起初我认为这可能与控件的 Mode 属性有关,但即使我将 Mode 更改为 PassThrough,它仍然不会呈现 title 属性的值。
编辑:文字的代码如下:
LiteralControl.Text = "<a href='test.jpg' title='title here' id='testimage' rel='hint-text: CLICK TO ZOOM' style='position: relative; display: inline-block'>image goes here</a>"
你们有没有人遇到这个问题并且碰巧知道解决方案?