1

我的应用程序中的 html 文本有问题。场景是,我可以将输入到编辑器(在我的情况下为 radeditor)中的文本保存到 xml 属性中。在保存的同时,我确实喜欢,

    Server.HtmlEncode(EditorGuidance.Content.Trim)

在我的代码的其他部分中,我需要从后面的代码中创建一个图像,并附加一个 onclick javascript 事件,将为此指导字段保存的值传递给 js 方法。

我喜欢,

    Dim desc As String = control.Descendants("controlGuidance").First().Attribute("description").Value
    lblGuidanceImage.Text = "<img onCliCk=""DisplayControlHelp('" & HttpUtility.HtmlDecode(desc.Replace("\", "\\").Replace("'", "\'")) & "')"" style=""vertical-align:middle; padding-right:2px; cursor: pointer;"" src=""../Images/help.gif"" alt=""Click for additional guidance"" title=""Click for additional guidance"" />&nbsp;"

现在,我编写的 js 方法必须在该页面中获取 radwindow 并在该窗口中显示传递的文本。

    function DisplayControlHelp(helpText) {
    var wnd = $find("<%=RdWndGuidance.ClientID %>");
    var controlGuidance = document.getElementById("<%= lblControlGuidance.ClientID %>");
    helpText = $("<div/>").text(helpText).html();
    controlGuidance.innerHTML = helpText;
    wnd.show();
    }

现在,这适用于其中没有 html 标签的文本。

但这失败(图像被呈现到页面,但点击事件不起作用)对于文本

    &lt;p style=&quot;list-style-type: none; font-size: 15px;  font-family: Georgia, Century, Times, serif;   color: #333333; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px 0px 15px;  line-height: 21px; padding-right: 0px;border: 0px;&quot;&gt;Around 3,000 patients died needlessly last year as a result of poor care, and nearly half a million were harmed unnecessarily in the NHS,&lt;a href=&quot;http://www.huffingtonpost.co.uk/news/jeremy-hunt&quot; style=&quot;list-style-type: none;    color: #058b7b; outline-width: 0px; padding-bottom: 0px; padding-top: 0px; outline-style: none; padding-left: 0px; text-decoration: none; margin: 0px;  outline-color: invert; padding-right: 0px;border: 0px;&quot; target=&quot;_hplink&quot;&gt;&amp;nbsp;Jeremy Hunt&lt;/a&gt;&amp;nbsp;will say today, as he calls on the health service to tackle the &quot;silent scandal of errors&quot;.&lt;/p&gt;&#xD;&#xA;&lt;p style=&quot;list-style-type: none; font-size: 15px;  font-family: Georgia, Century, Times, serif;   color: #333333; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px 0px 15px;  line-height: 21px; padding-right: 0px;border: 0px;&quot;&gt;The health service also recorded 326 &quot;never events&quot; - incidents so unacceptable that they should never happen in the last 12 months.&lt;/p&gt;&#xD;&#xA;&lt;p style=&quot;list-style-type: none; font-size: 15px;  font-family: Georgia, Century, Times, serif;   color: #333333; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px 0px 15px;  line-height: 21px; padding-right: 0px;border: 0px;&quot;&gt;The figures come amid revelations that the Care Quality Commission&amp;nbsp;&lt;a href=&quot;http://www.huffingtonpost.co.uk/2013/06/21/cqc-cover-up-jill-finney_n_3476518.html?utm_hp_ref=uk&quot; style=&quot;list-style-type: none;    color: #058b7b; outline-width: 0px; padding-bottom: 0px; padding-top: 0px; outline-style: none; padding-left: 0px; text-decoration: none; margin: 0px;  outline-color: invert; padding-right: 0px;border: 0px;&quot; target=&quot;_hplink&quot;&gt;covered up a spate of mother and baby deaths&lt;/a&gt;&amp;nbsp;at Morecambe Bay Trust, and days after it was&amp;nbsp;shown the NHS had paid up to&amp;nbsp;&lt;a href=&quot;http://www.huffingtonpost.co.uk/2013/06/12/nhs-gagging-orders_n_3426090.html&quot; style=&quot;list-style-type: none;    color: #058b7b; outline-width: 0px; padding-bottom: 0px; padding-top: 0px; outline-style: none; padding-left: 0px; text-decoration: none; margin: 0px;  outline-color: invert; padding-right: 0px;border: 0px;&quot; target=&quot;_hplink&quot;&gt;&amp;pound;2million to stop potential NHS whistleblowers&lt;/a&gt;from speaking out.&lt;/p&gt;

这是保存在 xml 中的 htmlencoded 文本

谁能让我知道做错了什么,或者我需要做些什么来解决这个问题。我尝试了很多方法,但还没有运气。

任何帮助表示赞赏。

4

0 回答 0