gpt4 book ai didi

javascript - 页面无故刷新

转载 作者:行者123 更新时间:2023-11-30 08:11:41 25 4
gpt4 key购买 nike

我的 asp.net 页面中有 2 个 LinkBut​​ton。当我点击第一个时,我希望第二个可见,所以我使用以下代码来实现它:

链接按钮:

<asp:LinkButton runat="server" id="LB1" OnClientClick="updateApplet(); return false;" Text="LB1" />

<asp:LinkButton runat="server" id="LB2" style="display: none;" Text="LB2" />

在 updateApplet() 函数中完成一些过程后,我希望 LB2 在完成所有操作后变得可见。但是asp页面无故刷新。

function updateApplet() {

var msg = document.capture.capture();
var hiddenControl = '<%= inpHide.ClientID %>';
document.getElementById(hiddenControl).value = msg;

document.getElementById('LB2').style.display = 'inherit';
// Without last line everything is perfect but I want LB2 is to be visible and this line refreshes my page :(
}

有人可以帮我解决我的问题吗?

最佳答案

请检查您的 updateApplet() 函数是否正常完成(即没有抛出 JavaScript 异常)。

从外观上看,您的最后一行导致 JavaScript 错误,然后 return false; 语句未被调用,因此默认的 LinkBut​​ton 行为被触发。

编辑: 是的,我找到了。你的第二个按钮的 ID 不是 LB2,你应该这样做

document.getElementById('<%= LB2.ClientID %>').style.display = 'inherit'; 

关于javascript - 页面无故刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9467377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com