I've heard and seen dedication used for both. The handwritten kind can be called inscription, as others have said, or an autograph (though this is more used when carrying a signature, possible of someone well-known).