如何在 ASP.NET 中创建框架(以显示 ASP.NET 站点中的其他 URL)

发布于 2024-12-12 08:44:06 字数 556 浏览 3 评论 0原文

场景:ASP.NET 网站的母版页具有顶部、左侧和侧边栏。页面正文有时需要显示其他网址的数据。例如,主页上会有一个名为“显示城市”的超链接。单击此链接将打开一个新窗口,其中 URL 为“https://yourcompany/cities.aspx”。此 ASPX 未链接到 ASP.NET 站点。

我想更改此设置以在 ASP.NET 站点本身中显示“https://yourcompany/cities.aspx”。因此,当用户单击“显示城市”时,网站将显示标题、顶部、左侧,正文将显示city.aspx 显示的任何结果。

最好的方法和建议是什么?我需要创建框架吗?在这方面需要一些帮助。

有关此的更多信息: MasterPage 有几个超链接或按钮,例如显示城市、显示经销商等。单击 ShowCities 应显示 yourcompany/cities.aspx(外部站点),类似地,单击“ShowDealers”应显示“mycompany.com/ShowDealers.aspx”。因此,每个链接都有其独特的点击和结果,但结果应显示在我们的网站内,这样用户就不会觉得自己被重定向到某个地方。此外,显示结果的区域/边界不应显示该外部站点的 URL

Scenario : ASP.NET site with masterpage that has top, left and side bars. The body of the page sometimes needs to be shown the data from other urls. For example there will be a hyperlink on the masterpage called "Show Cities". Clicking on this link will open a new window with url "https://yourcompany/cities.aspx". This ASPX is not linked to the ASP.NET site.

I would like to change this to show "https://yourcompany/cities.aspx" within ASP.NET site itself. So when users click on "Show cities", the site will show header, top, left and the body will show whatever results cities.aspx shows.

What is the best approach and suggestions? Is it like I need to create frames? Need some assistance in this regard.

More information on this:
MasterPage has few hyperlinks or buttons such as Show Cities, Show Dealers etc. Clicking on ShowCities should show yourcompany/cities.aspx (external site) and similarly "ShowDealers" click should show "mycompany.com/ShowDealers.aspx";. So each link has it's own unique click and results but results should be shown within our site such that user should not feel he is being redirected somewhere. Also the area/boundary where it shows the result should not show the URL of that external site

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮华 2024-12-19 08:44:06

标记:

<iframe id="yourid" runat="server" src="http://initialsource.aspx"> </iframe>

关于代码隐藏...

  yourid.src="http://to-the-new-site.aspx";

我认为它应该有效。

更新 - 提供js版本:

如果您定义这样的javascript函数:

function setFrameSrc(newSrc)
{
    document.getElementyById('yourid').src=newSrc;
    //note: 'yourid' is the iframe id from my initial example.
}

并且您的链接如下:

function setFrameSrc(newSrc)
{
    document.getElementById('yourid').src=newSrc;
    //note: 'yourid' is the iframe id from my initial example.
}

将会起作用。 在此处测试。

Markup:

<iframe id="yourid" runat="server" src="http://initialsource.aspx"> </iframe>

And on code behind...

  yourid.src="http://to-the-new-site.aspx";

I think it should work.

UPDATE - providing js version:

If you define a javascript function like this:

function setFrameSrc(newSrc)
{
    document.getElementyById('yourid').src=newSrc;
    //note: 'yourid' is the iframe id from my initial example.
}

And you have your link like this:

function setFrameSrc(newSrc)
{
    document.getElementById('yourid').src=newSrc;
    //note: 'yourid' is the iframe id from my initial example.
}

Will work. Test here.

难忘№最初的完美 2024-12-19 08:44:06

取决于来源的来源和目标受众。您可以在母版页中创建 city.aspx 页面,并将其主体设置为 IFrame,并将目标页面作为源。

工作得很好,但有些移动设备不支持 iFrame。

Depending on where the source is coming from and your target audience. You could create the cities.aspx page within your master page and simply set the body of it to be an IFrame with the target page as the source.

Works pretty well, but some mobile devices do not support iFrames.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文