button 只能提交一次

<asp:Button ID="Button1" runat="server" Text="· 提 交 ·" onclick="Button1_Click" UseSubmitBehavior="false" OnClientClick="clickOnce(this, 'Cargando...')"/>

 

<script type="text/javascript" language="javascript">
    function clickOnce(btn, msg) {
        // 验证是否做了验证
        if (typeof (Page_ClientValidate) == 'function') {
            // if we are doing a validation, return if it's false 
            if (Page_ClientValidate() == false) { return false; }
        }
        // Ensure that the button is not of type "submit"
        if (btn.getAttribute('type') == 'button') {
            // The msg attibute is absolutely optional
            // msg will be the text of the button while it's disabled
            if (!msg || (msg = 'undefined')) { msg = '提交中...'; }
            btn.value = msg;
            // The magic :D
            btn.disabled = true;
        }
        return true;
    }
</script>
posted @ 2010-04-05 15:56  王树羽  阅读(479)  评论(0编辑  收藏  举报