I know you want me to say it only lasts a week, and that they soon transition well and are back to normal. Unfortunately, I'd be lying through my teeth, so I'll tell you the real story. My daughter was climbing out of her crib at 25 months, so we transitioned to a toddler bed. For a few weeks, we had to sit by her door to make sure she stayed in bed. Then, we moved further and further away, until we were in the next room. But she'd still take an hour to get to sleep, and would come out of her room over and over and over again. She insists on her door being opened, so we tried closing the door, taking away stuffed animals, a sticker chart, the SuperNanny technique where you just silently put them back in bed over and over for a few nights until the get it. None of it worked. And a baby gate didn't work, because she just climbed over it.
This week, at 28 months, we have FINALLY made progress. And as bad as it sounds, we had to start getting a little mean with her. It was all a big game to her, and every time she'd come out of her room, she's smile and giggle and then run back to her room. So clearly, our tactics weren't working, and she was in total control, which is a bad idea. So this week, we put her to bed, and told her if she got up, we'd close the door. She got up, we put her in bed, and told her we now had to close the door, and if she got up again, we'd lock it (we switched the knob so the lock is on the outside). Sure enough, she got up again, so we put her back in bed, told her we had warned her and that we now had to lock the door, and locked the door. She screamed and cried and was mad, and we felt bad, but truly, she needed to get mad, because her thinking she was so funny with her antics just wasn't acceptable. After about 5 minutes, we opened the door, and told her if she stayed in bed, we could leave the door open, but if she got out of bed, we'd have to lock it again. And she went right to sleep! Granted, she was very tired that night, but it's been 4 nights, and she's been so, so much better. We only had to lock the door the first two nights. Ever since, she's gotten up just once and then gotten right back in bed and stayed there. She doesn't go to sleep right away, but she stays in bed, singing or playing with a stuffed animal, until she's asleep. I can't tell you what a relief this is to me!
So, I would try every other tactic first. Try a sticker chart - tell him he gets a sticker if he stays in bed, and if he gets X number of sticker (our chart has 10 spots), he gets to choose something special (it could be going for ice cream, a small toy, whatever). Try the Super Nanny technique - if he gets out of bed once, put him back and say "It's bedtime, love." If he gets out of bed again, put him back and just say, "It's bedtime" and any other time he gets out of bed, put him back in bed without eye contact or speaking to him. You'll have to try this a few nights to see if it works - one night is not enough.
But if all else fails, locking the door was the one thing that worked for us. I would never leave it locked all night, but just to get my point across for a few minutes. My daughter is going to sleep a bit later than she was at night, but she usually stays in bed all night now. Nap times can still be a struggle, but I sometimes nap with her, or again, threaten to close the door.
Good luck!