Can I create an ASP.NET ImageButton that doesn't postback?

前端 未结 8 533
无人及你
无人及你 2020-12-11 17:25

I\'m trying to use the ImageButton control for client-side script execution only. I can specify the client-side script to execute using the OnClientClick property, but how d

8条回答
  •  情话喂你
    2020-12-11 17:34

    Here's one way you could do it without conflicting with the postback functioning of other controls:

    Define your button something like this:

    
    

    The "my" ending in the handler for OnClientClick is a way to alias asp.net's __doPostBack client event that forces the postback; we simply override the behavior by doing nothing similar to this script:

    
    

    Edit: Yeesh, I feel like I need to take a shower after some of the dirty tricks that I need to pull in order to get asp.net to do what I want.

提交回复
热议问题