Provided is a strategy for generating transgenic plants with concurrent resistance to DNA and RNA viruses at one construction, so as to develop an RNA-directed DNA methylation (RdDM) transgenic system using a hairpin construct of Ageratum yellow vein virus (AYVV) promoter region residing in an intron to resist DNA virus infection by RdDM. Furthermore, the hairpin construct of the AYVV promoter region coupled with an untranslatable nucleocapsid protein (NP) fragment of Melon yellow sport virus (MYSV) is created to induce post-transcriptional gene silencing (PTGS) against MYSV. A method for providing transgenic plants conferring concurrent resistance to both AYVV and MYSV for control of DNA and RNA virus at the same time, and underlying RdDM and PTGS mechanisms, respectively, is also provided.