No person charged with any crime and called as a witness in his own behalf, shall be asked, or if asked, shall be required to answer, any question tending to show that he has committed, or been charged with, or been convicted of any offense other than the one wherewith he shall then be charged, or tending to show that he has been of bad character or reputation unless:
(1) he shall have at such trial, personally or by counsel, asked questions of the witness for the prosecution with a view to establish his own good reputation or character, or has given evidence tending to prove his own good character or reputation; or
(2) he shall have testified at such trial against a co-defendant, charged with the same offense.