我可以使用的UpdatePanel在母版包嵌套页面? [英] Can I use UpdatePanel in MasterPage to wrap nested pages?

查看:250
本文介绍了我可以使用的UpdatePanel在母版包嵌套页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用更新面板母版包嵌套页面,以便从一个页面浏览到其他客户端时,只得到了局部刷新(母版并没有得到重新加载)。

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).

如果这样 - 怎么样?难道我只是把周围的的ContentPlaceHolder 更新面板在母版页?

If so - how? Do I Just put an update panel around the ContentPlaceholder in the Master Page?

任何帮助AP preciated!

Any help appreciated!

推荐答案

我不建议你在包裹整个页面的的UpdatePanel ,其原因如下:

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 subject

由于这个庞大的开销,建议使用更新面板更新网站的只是小部分(如就在旁边的小盒子窗口小部件,等...),而不是全部内容部分。

Because 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.

在一个更新面板结束语内容部分意味着你将不得不加倍努力动态更改URL(使用#锚)手动自己,这是为了让你给用户使用背面的能力在他们的浏览器按钮即可进入该网站的previous部分。 不必回去页面的能力对于用户来说非常讨厌

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


下面是一个演示与的UpdatePanel 就是问题的例子。


以下是code与标签和一个按钮,一个简单的aspx页面:

Here is an example that demonstrates the problem with UpdatePanels.

The following is code for a simple aspx page with a label and a button :

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" ID="up1">
 <ContentTemplate>
   <asp:Label runat="server" ID="Label1" Text="Update Me!" /><br />
   <asp:Button runat="server" ID="Button1" 
     Text="Postback Update" OnClick="Button1_Click" />
 </ContentTemplate>
</asp:UpdatePanel>

&NBSP;

protected void Button1_Click(object sender, EventArgs e)
{
  Label1.Text = DateTime.Now.ToLongDateString();
}

和以下与的UpdatePanel 单击该按钮时(注意所涉及的巨大的开销)做了局部回传:


                  

And the following is a partial postback done with the UpdatePanel when the button is clicked (notice the huge overhead involved) :

                  

正如你所看到的,服务器基本上将所有的都在的UpdatePanel 返回给客户端。

As you can see, the server is basically sending all the elements that are in the UpdatePanel back to the client.


在另一方面,这里是涉及到使用的 ASP.Net页面方法。注意从服务器这次发送的响应(不涉及的UpdatePanel 的):

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) :

                    

                    

这篇关于我可以使用的UpdatePanel在母版包嵌套页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆