ASP.NET显示按钮点击DIV [英] ASP.NET show div on button click

查看:302
本文介绍了ASP.NET显示按钮点击DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示按钮点击加载分区,但它不是做什么工作的。

am trying to show a loading div on button click, but it is not working at the moment.

使用Javascript:

Javascript :

<script type="text/javascript">
        $(document).ready(function (e) {      
            $('#BtnSend').click(function () {
                $('#<%= loading.ClientID %>').toggle("slow");
            });
        });
    </script>

事业部:

<div id="loading" class="Loading" runat="server" visible="false">
  <div class="loadingImg">
    <img src="../Images/loading.gif" alt="loading" />
    </div>
  </div>

按钮:

<asp:Button ID="BtnSend" runat="server" Text="SEND" 
            onclick="BtnSend_Click" CssClass="pressbutton2" Height="36px" ClientIDMode="Static" />

在div设置为RUNAT服务器,这样我可以通过code也改变它的知名度。

the div is set to runat server so that I can change its visibility also through code.

推荐答案

使用的OnClientClick 为ASP按钮。然后,让jQuery的功能,你ahve名为 BtnSend_Click

Use the onClientClick for the asp button. Then make the jquery function that you ahve called BtnSend_Click

如果您想通过客户端来做到这一点:

If you want to do it via Client side:

jQuery的

function BtnSend_Click () {
     $('#<%= loading.ClientID %>').toggle("slow");
}

ASP按钮

<asp:Button ID="BtnSend" runat="server" Text="SEND" 
            onClientClick="BtnSend_Click" CssClass="pressbutton2" Height="36px" ClientIDMode="Static" />

如果您希望通过服务器来做到这一点:

If you want to do it via the server:

C#

protected void BtnSend_Click(object sender, EventArgs e){
     loading.Visibility = 'visible' //not sure on syntax to show it in code behind off the top my head
}

ASP按钮

<asp:Button ID="BtnSend" runat="server" Text="SEND" 
            onClick="BtnSend_Click" CssClass="pressbutton2" Height="36px" ClientIDMode="Static" />

这篇关于ASP.NET显示按钮点击DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆