I'm using a Telerik RadEditor to insert text with rich formatting. The problem is that my rdlc reports can format all of the html mark up except for <span style="text-decoration: underline;"> Underlined this Text </span>
. If I use <u>Underlined this Text</u>
it renders fine on the reports, but the control will not save it in that format. (yes I know <u>
is depreciated...).
What I'm wanting to do is update the record after it is inserted and replace any <span style="text-decoration: underline;">
tags with <u>
tags and their closing tags </span>
with </u>
. But I'm not sure how to do this in sql.
This is what a sample saved record currently looks like:
Plain Text <strong> Bold Text </strong><span style="color: #ff0000;"> Color Text </span>/<em><span style="text-decoration: underline;"> Underlined and Italics Text </span></em> and <span style="text-decoration: underline;"> Underlined Only Text </span>
This is what a sample saved record should look like:
Plain Text <strong> Bold Text </strong><span style="color: #ff0000;"> Color Text </span>/<em><u> Underlined and Italics Text </u></em> and <u> Underlined Only Text </u>
Any ideas as to how I can do this?
You can implement a custom content filter as shown below which will convert the span tag to U tag. Use the same approach for the other tags:
<telerik:radeditor runat="server"ID="RadEditor1" OnClientLoad="OnClientLoad" ContentFilters="MakeUrlsAbsolute,FixEnclosingP">
</telerik:radeditor>
<script type="text/javascript">
function OnClientLoad(editor, args) {
editor.get_filtersManager().add(new FixUnderline());
}
FixUnderline = function() {
FixUnderline.initializeBase(this);
this.IsDom = true;
this.Enabled = true;
this.Name = "FixUnderline";
this.Description = "This filter changes CSS underline to u tag";
};
FixUnderline.prototype = { _getElements: function(a, c) {
var b = a.getElementsByTagName(c);
if (!b) {
b = a.ownerDocument.getElementsByTagName(c);
} return b;
}, _replaceElementWithSpan: function(l, h, k) {
var m = this._getElements(l, h);
var d = [];
for (var b = m.length - 1; b >= 0; b--) {
Array.add(d, m[b]);
} for (var a = 0, c = d.length; a < c; a++) {
var e = l.ownerDocument.createElement("span");
e.style.cssText = k;
var f = d[a];
var g = f.innerHTML;
if ($telerik.isIE && g == " ") {
e.innerText = g;
} else {
Telerik.Web.UI.Editor.Utils.setElementInnerHtml(e, g);
} f.parentNode.replaceChild(e, f);
}
}, _replaceSpanWithElement: function(o, n, f) {
var q = this._getElements(o, "span");
var e = [];
for (var b = q.length - 1; b >= 0; b--) {
Array.add(e, q[b]);
} for (var a = 0, c = e.length; a < c; a++) {
var m = [];
var g = e[a];
for (var p = 0; p < g.childNodes.length; p++) {
Array.add(m, g.childNodes[p].cloneNode(true));
} if (g.style.cssText.toLowerCase() == f || g.style.cssText.toLowerCase() == (f + ";")) {
var h = o.ownerDocument.createElement(n);
for (var d = 0; d < m.length; d++) {
h.appendChild(m[d]);
} g.parentNode.replaceChild(h, g);
}
}
}, getHtmlContent: function(a) {
this._replaceSpanWithElement(a, "u", "text-decoration: underline");
return a;
}, getDesignContent: function(a) {
this._replaceElementWithSpan(a, "u", "text-decoration: underline");
return a;
}
};
FixUnderline.registerClass("FixUnderline", Telerik.Web.UI.Editor.Filter);
</script>
See more at https://www.telerik.com/forums/underline-in-radeditor-and-telerik-reporting and https://demos.telerik.com/aspnet-ajax/editor/examples/builtincontentfilters/defaultcs.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.