是否可以将 ASPX 页面嵌入到 ASCX 控件中?
问问题
996 次
2 回答
2
不。
这有点像在乘客座位上建造一辆汽车。
- 编辑:
需要明确的是,您可能会考虑获取内容的各种方法(例如实际请求它),然后将其包含在您的 ASCX 控件中,但总的来说,它会是一种非常“倒退”的方法。你想做什么?
于 2010-07-22T09:22:07.113 回答
0
iframe 实际上是可能的。
.ascx 控制代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Control.ascx.cs" Inherits="Project.Control" %>
<iframe id="ctrlIframe" runat="server" src="path/to/your_aspx_file.aspx"></iframe>
iframe 有链接到 aspx 页面。
您还需要调整 iframe 的大小以适应 ascx 控件中的 aspx:
<script type="text/javascript">
window.onload = function IFrameFitContent() {
var iframe = document.getElementById("<%= ctrlIframe.ClientID %>");
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var bWidth = iframe.contentWindow.document.body.scrollWidth;
var dWidth = iframe.contentWindow.document.documentElement.scrollWidth;
var height = Math.max(bHeight, dHeight);
var width = Math.max(dWidth, bWidth);
iframe.height = height;
iframe.width = width;
}
</script>
于 2020-10-27T08:39:08.647 回答