------解决方案-------------------- public string Filter(string s) { s = s.Replace("&","&"); s = s.Replace(" "," "); s = s.Replace("\"","""); s = s.Replace("<","<"); s = s.Replace(">",">"); return s; }
------解决方案-------------------- [DefaultProperty("Text"), ToolboxData("<{0}:LiteralRenderer runat=server></{0}:LiteralRenderer>"), ParseChildren(false, "Text")] public class LiteralRenderer : System.Web.UI.WebControls.WebControl { private string text;
[Bindable(true), Category("Appearance"), DefaultValue(""), PersistenceMode(PersistenceMode.InnerDefaultProperty)] public string Text { get { return text; }
private string Filter(string s) { if (s == null) return string.Empty; s = s.Replace("&","&"); s = s.Replace(" "," "); s = s.Replace("<","<"); s = s.Replace(">",">"); s = s.Replace("\"","""); return s; }
protected override void AddParsedSubObject(object obj) { text = text + Filter(RenderControlAsString((Control)obj));// }
public string RenderControlAsString(Control ctl) {