Hershey and Chase experiment
It is a matter of deduction. We know that:


Viruses entering a cell are capable of making more copies of themselves.
The only part of a virus that actually enters the cell is its DNA (or RNA, depending on the virus in question).


Based on these two facts, we can conclude that the DNA ̣--since it is the only part of the virus to enter the cell-- somehow contains the information necessary to make new copies of the virus and is, therefore, the genetic material of the virus.