[英]i want to call javascript pop up on Linkbutton but it post back the page and pop up is disappeared
function showdlgBox()
{
var whiteBox = document.getElementById("white-background");
var dlgbox = document.getElementById("dlgBox");
whiteBox.style.display = "block";
dlgbox.style.display = "block";`enter code here`
var winwidth = window.innerWidth;
var winHighet = window.innerHeight;`enter code here`
dlgbox.style.left = (winwidth / 2) - 480 / 2 + "px";
dlgbox.style.top = "150px";
}
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
How to Call this javascript on linkbutton
? 如何在
linkbutton
上调用此javascript?
Explanation: 说明:
As far as I understand it, that 据我了解,那
OnClick="LinkButton1_Click"
gets linked to the back end (server side) function - this is why the post back occurs. 链接到后端(服务器端)功能 - 这就是回发的原因。
Solution: 解:
Perhaps try taking it out. 也许尝试把它拿出来。 Or alternatively, use pure html anchor tag:
或者,使用纯html锚标记:
<a id='LinkButton1' href='javascript:void(0)'></a>
Good Luck 祝好运
Call javascript function onclientclick
在
onclientclick
调用javascript函数
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" onClientClick="return showdlgBox()">LinkButton</asp:LinkButton>
and in javascript function return false; 并在javascript函数中返回false;
function showdlgBox() {
var whiteBox = document.getElementById("white-background");
var dlgbox = document.getElementById("dlgBox");
whiteBox.style.display = "block";
dlgbox.style.display = "block";`enter code here`
var winwidth = window.innerWidth;
var winHighet = window.innerHeight;`enter code here`
dlgbox.style.left = (winwidth / 2) - 480 / 2 + "px";
dlgbox.style.top = "150px";
return false;
}
This should do the trick. 这应该可以解决问题。
使用OnClientClick="showdlgBox();"
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="showdlgBox();">LinkButton</asp:LinkButton>
you can use modal in bootstrap.. 你可以在bootstrap中使用modal ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.