单击按钮ASP.NET后停止刷新 [英] Stop refresh after click button ASP.NET
问题描述
我想点击按钮后页面停止刷新
< asp:LinkButton ID =btneqviewrunat =serverText =' <%#Eval(CCSEQID)%>'OnClientClick =btneqview_CommandOnCommand =btneqview_CommandCommandArgument ='<%#Eval(CCSEQID)%>'>
代码背后:
受保护的子btneqview_Command(ByVal sender As Object,ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Dim eqid As String = e.CommandArgument.ToString()
Dim url As String =MasterlistEquipmentDetails.aspx
Dim s As String =window.open('& url&?&eqid =& eqid&','popup_window','width = 1150,height = 650,left = 10,top = 10,resizable = no');
ClientScript.RegisterStartupScript(Me.GetType(),script,s,True)
End Sub
然而,每当我按下按钮,整个页面都会刷新。
有没有人有解决方案,或者它真的不可能?
我尝试过:
使用!PagePoad中的IsPostBack //但页面仍然刷新完全。我根本不想调用Page_Load。
Hi, I want the page stop refresh after I click the button
<asp:LinkButton ID="btneqview" runat="server" Text='<%# Eval("CCSEQID")%>' OnClientClick="btneqview_Command" OnCommand="btneqview_Command" CommandArgument='<%# Eval("CCSEQID") %>'>
Code behind :
Protected Sub btneqview_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Dim eqid As String = e.CommandArgument.ToString()
Dim url As String = "MasterlistEquipmentDetails.aspx"
Dim s As String = "window.open('" & url & "?" & "eqid=" & eqid & "', 'popup_window', 'width=1150,height=650,left=10,top=10,resizable=no');"
ClientScript.RegisterStartupScript(Me.GetType(), "script", s, True)
End Sub
However, whenever I press the button, the entire page gets refreshed.
Does anyone have a solution to this, or is it really impossible?
What I have tried:
Use !IsPostBack in Page_Load // but the page still refreshes completely. I don't want Page_Load to be called at all.
推荐答案
您可以使用ajax调用而不是单击事件服务器端。
当您的按钮是
Rather than making the button click event server-side you can make use of ajax calls.
When your button is
runat="server"
然后,当您点击整个页面时,生命周期会重复,因此感觉就像刷新一样,因为在现实,页面重新加载。
如果您不熟悉该术语,可以在CP上搜索关于ajax的文章。
你可以开始这里 [ ^ ]。
then whenever you click the whole page life cycle is repeated and hence it feels, like a refresh because in reality, the page reloads.
You can search on CP for articles on ajax if you're not familiar with the term.
You can start here[^].
这篇关于单击按钮ASP.NET后停止刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!