DS1 does this as well. I have found that saying no in a firm voice while holding his legs so he can't move works for about a minute. This is great if it is a pooey nappy as I can get him clean before he starts thrashing around again. Also giving a treat if he behaves himself works as well. The treat can be playing on the swing, playing with blocks or getting some sultanas (all of which are his top 3 things).

My absolute last resort is putting him on the ground without putting on a new nappy or pants and walking away. He hates going 'commando' so chases after me to put his nappy back on. I try not to do this too often as he gets a little upset.