Using themed css files requires a header control on the page. (e.g. <head runat=“server” />)
2012-03-02 11:13
591 查看
由于项目需要需要将XML字符串显示在浏览器中,具有可收缩的“+”和“-”,通过一段时间的测试,一开始使用Webbrowser,在WPF中的Webbrowser只能Navigate文件才可以显示,如果使用Winform中使用Webbrowser,则需要引用WindowsFormsIntegration和System.Windows.Forms,在WPF中将Winform的Webbrowser放入WindowsFormsIntegration中的WindowsFormsHost里面就行了,但是Winform的Webbrowser也只能用Navigate来定位文件,和shdocvw.dll中的Webbrowser接口一样,但是Winform中的Webbrowser还有DocumentText和DocumentStream,但是给这两个属性赋值后,XML会被解析成文本,最后在网上发现可以使用以下代码实现
而以上代码要正确运行,前台Aspx页面只能留下最顶上面的一句代码,其他的Html什么的都得删除,因为XML自己要作为根节点,例如Aspx页面如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequestMessagePage.aspx.cs" Inherits="MyNameSpace.RequestMessagePage" %>
但是项目中又在Web.config中使用了 <pages theme="Default" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
导致所有页面要应用Default中定义的所有样式,由于以上页面没有Header,导致“Using themed css files requires a header control on the page. (e.g. <head runat=“server” />)”异常的出现。在网上搜索了下使用 EnableTheming="false" StylesheetTheme="",但是仍然没有效果。
最后通过在页面文件中添加如下代码来禁止该显示XML页面应用样式终于成功了
最后一点本项目是在一个页面中嵌入这个显示XML的页面,通过iframe来承载XML页面,通过Session来传递需要的值来完成的。
Response.Charset = "utf-8"; Response.ContentType = "text/xml"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8"); Response.Write(XML);//要传入的字符串
而以上代码要正确运行,前台Aspx页面只能留下最顶上面的一句代码,其他的Html什么的都得删除,因为XML自己要作为根节点,例如Aspx页面如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequestMessagePage.aspx.cs" Inherits="MyNameSpace.RequestMessagePage" %>
但是项目中又在Web.config中使用了 <pages theme="Default" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
导致所有页面要应用Default中定义的所有样式,由于以上页面没有Header,导致“Using themed css files requires a header control on the page. (e.g. <head runat=“server” />)”异常的出现。在网上搜索了下使用 EnableTheming="false" StylesheetTheme="",但是仍然没有效果。
最后通过在页面文件中添加如下代码来禁止该显示XML页面应用样式终于成功了
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); this.Theme = null; }
最后一点本项目是在一个页面中嵌入这个显示XML的页面,通过iframe来承载XML页面,通过Session来传递需要的值来完成的。
相关文章推荐
- 排除“使用主题 css 文件要求页上有标头控件。(例如 <head runat="server" />)”错误
- Including header files using "" vs <>
- What is the difference between angle bracket < > and double quotes " " while including header files
- Tomcat --> Cannot create a server using the selected type
- WLS Exception: <BEA-149132> <Split-dir application HRSystem can only be deployed to the Admin Server
- asp.net页面间传值的几种方法 表单提交 传送页面代码 复制代码 <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- Note on <Beginning Microsoft SQL Server 2012 Programming> - 02
- Tomcat --> Cannot create a server using the selected type
- The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- 在struts-2.2.3.1中加入<s:head theme="ajax"/>这个标签,报错
- asp.net当修改header时提示:The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- Tomcat --> Cannot create a server using the selected type
- Tomcat --> Cannot create a server using the selected type
- <BEA-000388> <JVM called WLS shutdown hook. The server will force shutdown now>
- Note on <Beginning Microsoft SQL Server 2012 Programming> - 05
- <%%>与<scriptrunat=server>,<%=%>与<%#%>的区别
- 解决“No 'Access-Control-Allow-Origin' header is present on the requested resource.”
- <Error> <Server> <BEA-002606> <Unable to create a server socket for listening on channel "Default[2
- CSS学习之<img> & Background - CSS: The Missing Manual