ASP.NET: OnServerClick event handler not called if using onclick

后端 未结 8 1673
囚心锁ツ
囚心锁ツ 2020-12-05 21:35

I have a peculiar problem here and I can\'t by my life figure out what the solution is. Note that the following code is not dynamically created, but just immediatel

8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 21:54

    It sounds like the onclick event isn't bubbling through.

    You should just be able to use

    OnClientClick="return confirm('Sure?');
    

    I don't think the other onClick should be necessary.

    Edit:

    This method would require you to hook your function to the OnClick event manually.


    I am making up attributes this morning so in a futile effort to redeem myself-

    Another method would be to insert javascript to catch the event. Something like..

    $("form").submit(function() {
    
            var resp = confirm("Save & Submit?");
            if (resp) {
                serializeStats();
                return true;
            }
            else {
                return false;
            }
    
        });
    

    I do recall there being a better inline way to do this though. Caffeine time now.

提交回复
热议问题