Sorry but I strongly disagree with kneeing your dog to get it to stop jumping up. Yes it may work, but it may also hurt him, seriously. There are more sensible approaches like turning your back, or training him to sit when being praise and petted, or even using a leash or keeping a short long line on for control.
Don't get me wrong, if you use this technique and it works for you, then great! But I would suggest you try the others before resorting to this one.