我可以在 MasterPage 中使用 UpdatePanel 来包装嵌套页面吗?
我可以使用母版页中的更新面板来包装嵌套页面,以便从一个页面浏览到另一个客户端时仅获得部分刷新(母版页不会重新加载)。
如果是这样 - 怎么办? 我是否只需在母版页中的 ContentPlaceholder
周围放置一个更新面板?
任何帮助表示赞赏!
Can I use Update panel in masterpage to wrap nested pages so that when browsing from one page to the other client only gets a partial refresh (MasterPage doesn't get reloaded).
If so - how? Do I Just put an update panel around the ContentPlaceholder
in the Master Page?
Any help appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不建议您将整个页面包含在
UpdatePanel
中,原因如下:如果您希望搜索引擎将您的网站编入索引,您将需要在单独的页面上显示您的内容...只需在每个内容部分上使用不同的查询字符串就足够了。 这是因为对于搜索引擎来说内容为王并且由于搜索引擎目前无法索引动态生成的数据,因此它们将无法索引您的网页。
将整个页面包含在
更新面板
中是非常危险的,因为发送到服务器的开销巨大。 如果这样做,您会发现性能显着下降。 阅读这篇文章了解更多信息主题更新面板
来仅更新网站的一小部分(例如侧面的小框小部件,等...)而不是整个内容部分。将内容部分包含在更新面板中意味着您必须自己手动动态更改 url(使用 # 锚点),这样您就可以让用户能够使用其上的后退按钮浏览器转到网站的上一部分。 无法返回页面对于用户来说非常烦人
以下示例演示了
UpdatePanel
的问题。以下是带有标签和按钮的简单 aspx 页面的代码
:
以下是单击按钮时使用
UpdatePanel
完成的部分回发(请注意涉及的巨大开销):(来源:encosia.com)
正如您所看到的,服务器基本上将
UpdatePanel
中的所有元素发送回客户端。另一方面,这里是一个涉及使用 ASP.Net 页面方法。 请注意这次从服务器发送的响应(不涉及 UpdatePanel)
:
(来源:encosia.com)
I do not advise you to wrap an entire page in an
UpdatePanel
, for the following reasons:If you want your site to be index by Search Engines, you will need to display your content on separate pages...just having a different querystring on each content section is enough. This is because for search engines Content Is King and since search engines currently cannot index dynamically generated data, they will not be able to index your pages.
Wrapping entire pages in an
Update Panel
is very dangerous because of the huge overhead that is sent to the server. You will see a significant performance decrease if you do so. Read this article for more information on the subjectBecause of this huge overhead, it is suggested to use the
Update Panel
to update just small sections of the website (like little box widgets on the side, etc...) and not whole content sections.Wrapping content sections in an update panel means that you will have to go the extra mile dynamically changing the url (using # anchors) manually yourself, and this is so that you will give users the ability to use the back button on their browser to go to the previous section of the site. Not having the ability to go back in a page is very annoying for users
Here is an example that demonstrates the problem with
UpdatePanel
s.The following is code for a simple aspx page with a label and a button :
And the following is a partial postback done with the
UpdatePanel
when the button is clicked (notice the huge overhead involved) :(source: encosia.com)
As you can see, the server is basically sending all the elements that are in the
UpdatePanel
back to the client.On the other hand, here is an example that involves using ASP.Net Page Methods. Notice the response sent from the server this time (no UpdatePanels involved) :
(source: encosia.com)