[英]Disable page reload in update panel
I have an ASP.NET page with an update panel. 我有一个带有更新面板的ASP.NET页面。 Normally, if I use an update panel, there should be postbacks only but no complete page reloads.
通常,如果我使用更新面板,则应该只有回发,而没有完整的页面重新加载。
In my case, when I click a button, it always makes an page reload. 就我而言,当我单击一个按钮时,它总是使页面重新加载。 Although this button is in an update panel.
尽管此按钮位于更新面板中。
What I found out: When I put 我发现的东西:当我把
Response.End();
in the Button_Click Method, there is no reload. 在Button_Click方法中,没有重新加载。
My code on the .aspx: 我在.aspx上的代码:
<asp:UpdatePanel ID="upUserDefault" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnPrintSelectedArticles" />
</Triggers>
<ContentTemplate>
<cc1:MenuButton runat="server" ID="btnPrintSelectedArticles" OnClientClick="return ShowPrintStickersPopUp();" ButtonText="Print" />
</ContentTemplate>
</asp:UpdatePanel>
Code behind: 后面的代码:
Page Load: 页面加载:
btnPrintSelectedArticles.MenuButton_Click += btnPrintSelectedArticles_MenuButton_Click;
Method: 方法:
void btnPrintSelectedArticles_MenuButton_Click(object sender, EventArgs e)
{
// Disables reload
Response.End();
}
MenuButton is a user control MenuButton是一个用户控件
Any ideas how to disable the reload of the complete page? 有什么想法如何禁用整个页面的重新加载吗?
Edit: This is the ShowPrintStickersPopUp JS from the ClienClick. 编辑:这是来自ClienClick的ShowPrintStickersPopUp JS。 It simply checks a gridview if there are any checkboxes checked
它只是检查gridview是否选中了任何复选框
function ShowPrintStickersPopUp() {
var gridView = document.getElementById('<% =gvArticles.ClientID %>');
//get all the control of the type INPUT in the base control.
var inputs = gridView.getElementsByTagName("input");
for (var n = 0; n < inputs.length; ++n) {
if (inputs[n].type == 'checkbox' && inputs[n].checked) {
// If at least 1 checkbox is checked, open popup
window.open('PrintStickersPopUp.aspx', 'Print Stickers', 'width=700,height=550');
return true;
}
}
return false;
}
Your client method looks good. 您的客户端方法看起来不错。 Did you remember to add a ScriptManager object on your page?
您还记得在页面上添加ScriptManager对象吗? A lot of issues relating to UpdatePanels are related to not having one added.
与UpdatePanels有关的许多问题与未添加一个有关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.