繁体   English   中英

在 MasterPage 内的 div 标记内加载具有 pagemethods 的页面

[英]Load a page with pagemethods inside a div tag inside a MasterPage

我有一个 MasterPage,它将出现在应用程序的每个页面中,我正在尝试加载一个“LoginBox”,它在此 MasterPage 的 Div 标记内使用 PageMethods

到目前为止,我已经尝试过像在内容页面上所做的那样,尝试将其转换为用户控件并尝试使用服务器端包含 (<.--#include file="LoginBox.aspx"-->) 没有成功。

我可以通过 firebug 看到 webresources 已加载,但在任何这些方法中都没有创建 PageMethods javascript。

真的想避免为此创建一个 WebService,并且移动 LoginBox 不是一种选择,我宁愿放弃 MasterPage 的想法,但这样维护就会变成地狱。

我需要这方面的想法或方向。 任何帮助表示赞赏

我使用从 javascript 加载的 iframe 成功地工作,对我来说这是一个丑陋的解决方案,但仍然是一个。 我愿意寻求更好的解决方案

<script type="text/javascript"> 
    (function () {
        var e = document.createElement('iframe');
        e.setAttribute("src", "LoginBox.aspx");
        e.setAttribute("scrolling", "no");
        e.setAttribute("frameborder", "0");
        e.setAttribute("height", "73px");
        e.setAttribute("width", "225px");
        e.setAttribute("marginheight", "0px");
        e.setAttribute("marginwidth", "0px");
        e.async = true;
        document.getElementById('loginboxd').appendChild(e);
    } ());
</script>

在我看来你正在用 ASP.NET 捣碎经典的 asp

用户控件的重点是准确封装您在这里所做的事情。

即便如此,您会发现您尝试将代码组件化仍然会导致一团糟。 如果可以的话,考虑转移到 ASP.NET MVC。 有了它,您可以做更合适和更清洁的事情来保持代码库的清洁。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM