簡體   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