简体   繁体   English

我该如何在vb.net上显示我的模式弹出窗口

[英]what should I do at vb.net to display my modal pop up

<asp:Button ID="btnupdate" runat="server" Text="UPDATE" ValidationGroup="check" />

        <div id="msgdiv" class="modal">
            <!-- Modal content -->
            <div class="modal-content">
                <span class="close">×</span>
                <p>
                    update ok confirm pls login again!!!!!!</p>
            </div>
        </div>

     <script>


        var modal = document.getElementById('msgdiv'); 


        var btn = document.getElementById("btnupdate"); 


        var span = document.getElementsByClassName("close")[0];

        btn.onclick = function () {
            modal.style.display = "block";
        }

        span.onclick = function () {
            modal.style.display = "none";
        }

    </script>

This code is for the modal pop up message. 该代码用于模式弹出消息。 When I click on the button it should show the modal pop up then when I click the "x" button then it should close. 当我单击按钮时,它应该显示模式弹出窗口,然后当我单击“ x”按钮时,它应该关闭。

The problem is when you click on the update button it shows the modal pop up but immediately goes off. 问题是,当您单击更新按钮时,它会弹出模式对话框,但立即消失。 "its like, it is there but not" “就像,它在那里,但不在那里”

Should I do anything at back-end code or it can be fixed in front-end code, and how? 我应该在后端代码中执行任何操作,还是可以在前端代码中对其进行修复?如何?

Remove asp:button and make it just input type, runat server: 删除asp:button并使其成为输入类型,运行服务器:

<input ID="btnupdate" runat="server" type="button" value="UPDATE" ValidationGroup="check" />

        <div id="msgdiv" class="modal">
            <!-- Modal content -->
            <div class="modal-content">
                <span class="close">×</span>
                <p>
                    update ok confirm pls login again!!!!!!</p>
            </div>
        </div>

     <script>


        var modal = document.getElementById('msgdiv'); 


        var btn = document.getElementById("btnupdate"); 


        var span = document.getElementsByClassName("close")[0];

        btn.onclick = function () {
            modal.style.display = "block";
        }

        span.onclick = function () {
            modal.style.display = "none";
        }

    </script>

The reason that it is disappearing it because the button is posting back and reloading the form it just does it so quickly that you do not see it. 之所以消失,是因为该按钮正在回发并重新加载表单,它是如此之快以至于您看不到它。

ASP.NET Button is always submit button (input). ASP.NET Button始终是submit按钮(输入)。 This server-side tag has an attribute OnClientClick which is very useful here. 该服务器端标记具有OnClientClick属性,在这里非常有用。

<asp:Button ID="btnupdate" runat="server" OnClientClick="return showModal()" Text="UPDATE" ValidationGroup="check" />
<%--Note "return" --%>
...
<script>
function showModal(){
   //do what you need to show
   return false; //prefent form submission
}
</script>

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

相关问题 仅在进行表单验证后,如何才能弹出模态? - How do I get my modal to pop up only after validation in form occurs? javascript弹出框显示,背景半透明,我该怎么办 - javascript pop-up box show , background translucence,what should i do 如何在成功提交表单时创建弹出模式? - How do I create a pop up modal on successful form submission? 如何将弹出模式的值传递给原始表 - How do I pass the values of the pop up modal to the original table 您应该将 vb.net 应用程序专用的 html 文件放在 vb.net 应用程序中的哪个文件夹中? - What folder in a vb.net app should you put an html file used exclusively by the vb.net app? 弹出模态 Asp.Net 重定向 - Pop Up Modal Asp.Net redirect 我想添加一个弹出模式框 - I want to add a pop up modal box 为什么我的模态框会弹出一条消息,当我尝试使用基于我单击的数据填充它时,显示传入的对象无效 - Why does my modal box pop up with a message that says invalid object passed in when I try populate it with data based on what I have clicked 如何修复HTML中的弹出窗口? - How do I fix my pop up in html? VB.NET调用Javascript函数。 如何在VB.NET完成之前完成javascript函数? - VB.NET calls Javascript function. How do I get javascript function to complete before VB.NET completes?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM