如何在 ASP.NET 中创建框架(以显示 ASP.NET 站点中的其他 URL)
场景: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标记:
关于代码隐藏...
我认为它应该有效。
更新 - 提供js版本:
如果您定义这样的javascript函数:
并且您的链接如下:
将会起作用。 在此处测试。
Markup:
And on code behind...
I think it should work.
UPDATE - providing js version:
If you define a javascript function like this:
And you have your link like this:
Will work. Test here.
取决于来源的来源和目标受众。您可以在母版页中创建 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.