简体   繁体   English

如何在不重新加载页面的情况下触发更新面板

[英]How to trigger an Update Panel without Page Loading all again

Here is the thing: 这是事情:

I have a Master Page, and a couple of other Web Forms. 我有一个母版页,以及两个其他Web窗体。 All of them invoke User Controls, and inside the User Controls, there is an Update Panel. 它们全部都调用用户控件,并且在用户控件内部有一个“更新面板”。

Now that I add a button in the Master Page (all the pages will need that button, that's why it is in the Master Page), I need that button to show a Popup. 现在,我在母版页中添加了一个按钮(所有页面都需要该按钮,这就是它在母版页中的原因),我需要该按钮来显示弹出窗口。 That's ok. 没关系。

The problem is that when I click the button, the page rendered again. 问题是,当我单击按钮时,页面再次呈现。 So I put the button inside an Update Panel and set it as an Async Trigger for the Update Panel. 因此,我将按钮放在“更新面板”中,并将其设置为“更新面板”的异步触发器。

(imagine something like that: Master page{ update panel { button } content place holder } ) (想象一下:母版页{更新面板{按钮}内容占位符})

Now the page does not render again, but still launch the Page Load, and that is a problem. 现在页面不再呈现,但是仍然启动页面加载,这是一个问题。 If a page takes 5 seconds to show, because it is loading the content, the button in the master page will take 5 seconds too, because it will load all again. 如果某个页面需要5秒钟才能显示,因为它正在加载内容,母版页中的按钮也将需要5秒钟,因为它将再次加载所有内容。

Does someone know something to fix that? 有人知道一些解决办法吗?

I assume it's an asp.net standard button like 我认为这是一个asp.net标准按钮,例如

 <asp:Button ID="Button1" runat="server" Text="Button" />

So on click of this button it fires a postback event. 因此,单击此按钮将触发回发事件。 But the button needs to show a popup only and if no server code processing is required, better to use 但是该按钮仅需要显示一个弹出窗口,如果不需要服务器代码处理,则最好使用

<input type="button" id="Button1" value="Button"/>

Remove UpdatePanel. 删除UpdatePanel。

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

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