繁体   English   中英

onclick事件不工作asp.net

[英]onclick event not working asp.net

我喜欢这个按钮,它的按钮点击不起作用

<asp:Button ID="btnfirstnext" runat="server" Text="Next" class="next1 action-button" OnClick="btnfirstnext_Click" OnClientClick="return false;" />

在这里,我使用JavaScript之类的

$(".next1").click(function () {
            if (animating) return true;
            animating = true;

            current_fs = $(this).parent();
            next_fs = $(this).parent().next();

            //activate next step on progressbar using the index of next_fs
            $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");

            //show the next fieldset
            next_fs.show();

            //hide the current fieldset with style
            current_fs.animate({ opacity: 0 }, {
                step: function (now, mx) {
                    //as the opacity of current_fs reduces to 0 - stored in "now"
                    //1. scale current_fs down to 80%
                    scale = 1 - (1 - now) * 0.2;
                    //2. bring next_fs from the right(50%)
                    left = (now * 50) + "%";
                    //3. increase opacity of next_fs to 1 as it moves in
                    opacity = 1 - now;
                    current_fs.css({ 'transform': 'scale(' + scale + ')' });
                    next_fs.css({ 'left': left, 'opacity': opacity });
                },
                duration: 800,
                complete: function () {
                    current_fs.hide();
                    animating = false;
                },
                //this comes from the custom easing plugin
                easing: 'easeInOutBack'
              // $('btnfirstnext').trigger('click');

            });
        });

我想在按钮clickevent上运行一些代码

protected void btnfirstnext_Click(object sender, EventArgs e)
    {
        lblmessage.text="Hello this button click working";

    }

在这里你可以看到上面这个细节,当我加载这个代码它只运行JavaScript而不是工作按钮点击事件。 这个JavaScript是一个弹出窗口。 请帮我解决这个问题。

请删除OnClientClick="return false;" 参与aspx。 我怀疑这是在阻止回发。

你从OnClientClick返回false ,如果你从OnClientClick javascript事件处理程序返回false,那么你不会收到回发的帖子,如果你总是需要回发,你可以总是返回true。 否则,您可以有条件地返回true或false。

仅使用您拥有的jQuery click事件处理程序并删除On OnClientClick

尝试这个:

$(document).ready(function(){
  $(".next1").click(function () {

   //Your Code here


  });
});

并删除它: OnClientClick="return false;"

你需要删除OnClientClick="return false;" 在你的asp:Button 它阻止了你的回发。 你的按钮需要看起来像这样:

<asp:Button ID="btnfirstnext" runat="server" Text="Next" class="next1 action-button" OnClick="btnfirstnext_Click" />

我只会使用click事件处理程序来处理这个问题。 我还要添加document ready部分:

$(document).ready(function() {
     $(".next1").click(function() {
          // Add the rest of your code
     });
});

我希望这有帮助。

<asp:Button ID="btnfirstnext" runat="server" Text="Next" class="next1 action-button" OnClick="btnfirstnext_Click"; />

你必须删除OnClientClick =“return false;”。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM