[英]How to create aspx page on runtime and place literal control?
I have an requirement where i have to display some content on iframe dynamically. 我有一个必须在iframe上动态显示一些内容的要求。 Let me explain my scenario.
让我解释一下我的情况。 I have a form where i have to display some html text.
我有一个表格,我必须显示一些html文本。 Earlier what i did is , i placed a literal on the form and fill it with HTML text.
早先我做的是,我在表格上放置了文字,并用HTML文本填充了文字。 All worked fine but , the text alignments of the displayed html gets overriden by the page css.
一切正常,但显示的html的文本对齐方式被页面css覆盖。 So what i want now is that, instead of literal, i place an iframe.
因此,我现在想要的是放置一个iframe而不是字面值。 Now at page load event , i will generate a aspx dynamically and place a literal control and fill that literal control with the html text.
现在在页面加载事件中,我将动态生成一个aspx并放置一个文字控件,并用html文本填充该文字控件。 And then will display that aspx page in the iframe.
然后将在iframe中显示该aspx页面。
So i would like to know the following things: 所以我想知道以下几件事:
Is this a good idea to hold heavy text , more than 20K of chars in memory, dynamically generate aspx page at runtime. 将大量文本(超过20K的字符)存储在内存中,并在运行时动态生成aspx页面是一个好主意吗?
If any workaround to not to inherit the page css inside the literal displayed. 如果有任何解决方法,以不继承显示的文字内的页面CSS。
Any other approach better than my approach. 任何其他方法都比我的方法更好。
--- I am using ASP.NET / C# 4.0 - 我正在使用ASP.NET/C# 4.0
Loads of questions... 大量的问题...
Thanks in advance 提前致谢
AmRan, if this actually is a css problem, I would first try to create separate css styles for that content and use with the first solution you did. AmRan,如果这实际上是一个CSS问题,我将首先尝试为该内容创建单独的CSS样式,并与您执行的第一个解决方案一起使用。 For example, wrap your dynamic content widh
例如,将动态内容包装
<div id="dynamicContent">
tag and place 标签和位置
#dynamic {}
style settings inside your css file. CSS文件中的样式设置。
I don't think the Literal control has a CssClass property so you would have to use Label instead, or some other technique. 我不认为Literal控件具有CssClass属性,因此您将不得不使用Label或其他某种技术。
I would try to stay away from IFrame solutions if possible. 如果可能,我会尽量避免使用iframe解决方案。
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.