覆盖渲染SharePoint页面上 [英] Overriding Render on Sharepoint page

查看:103
本文介绍了覆盖渲染SharePoint页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经重写SharePoint页面的渲染方法,从发送到客户端浏览器这样的HTML切出一些脚本标签:

I have overriden Sharepoint page's Render method to cut out some script tag from the html sent to client browser like this:

protected override void Render(HtmlTextWriter originalWriter)
    {   
        string content = string.Empty;
        using (StringWriter stringWriter = new StringWriter())
        {
            using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
            {
                //render the page to my temp writer
                base.Render(htmlWriter);
                htmlWriter.Close();
                //get page content that would normally be sent to client
                content = stringWriter.ToString();
                stringWriter.Close();
            }
        }
        //replace the script tag
        Regex regex = new Regex(@"<script>.*RTE_ConvertTextAreaToRichEdit.*<"+"/script>");
        content = regex.Replace(content, string.Empty);

        //write modified html to the original writer
        originalWriter.Write(content);
    }

这种变化奇怪的事情发生后:页面的一部分,通常是在右上角,并说欢迎光临XXX无法正确显示。当我查看该页面的源代码,这段文字writter BEFORE HTML标记 - 任何HTML开始之前。我也弄不清是怎么回事了最后两天。

你有什么想法,有没有人有类似的问题?

After this change something strange happened: a part of page that usually is in the upper-right corner and says "Welcome XXX" is not displayed properly. When I view the source of the page, this text is writter BEFORE HTML tag - before any html starts. I can't figure out what is going on for last two days.
Have you got any ideas, has anyone had similar problem?

推荐答案

您可以使用HTML敏捷包一些运气。 HTML解析器是更好的... ...解析HTML比regexs的。

You may have some luck using the HTML agility pack. HTML Parsers are better at... parsing... html than regexs are.

HTTP://www.$c$cplex.com/htmlagilitypack

这篇关于覆盖渲染SharePoint页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆