Asp Radiobuttonlist甚至在从js返回false后导致回发

时间:2015-07-23 11:25:07

标签: javascript jquery asp.net radiobuttonlist

HTML:

<asp:RadioButtonList ID="rdStatus" runat="server" Height="48px" 
  RepeatDirection="Horizontal" AutoPostBack="true" 
  OnSelectedIndexChanged="rdStatus_SelectedIndexChanged" CssClass="rad">                                                                         
    <asp:ListItem Text="Active" Value="1"></asp:ListItem>                                                            
    <asp:ListItem Text="Deactive" Value="0"></asp:ListItem> 
 </asp:RadioButtonList>

JQuery的:

$(".rad").click(function () {
      return confirm("Do you really want to change status?");
         });

无论是否在确认框中单击“确定”或“取消”,它都会导致回发。

2 个答案:

答案 0 :(得分:-1)

 if (!confirm('Do you really want to change status?')){
         return false;enter code here
    }
    else{
         return true;
    }

答案 1 :(得分:-1)

&#13;
&#13;
 <script type="text/javascript">
        $(document).ready(function () {
            $(".rad").click(function () {

                var a = confirm('Do you really want to change status?');
                
                if (a==false) {
                    return false;
                }
                else {
                    return true;
                }
            });
        });

        




    </script>
&#13;
&#13;
&#13;