Assisted by a new dissolution procedure, dicyandiamide (DCDA), an environmentally benign and cheap precursor, has been employed for the synthesis of mesoporous carbon nitride (CN) materials through a nanocasting approach. The synthesized mesoporous materials possessed high specific surface areas (269-715 m(2) g(-1)) with narrow pore-size distributions (about 5 nm) and faithfully replicated the mesostructures of the SBA-15 and FDU-12 templates. Several characterization techniques, including XRD, SAXS, TEM, Raman and FTIR spectroscopy, XPS, and CO2-TPD, were used to analyze the physicochemical properties of these materials and the results showed that the mesoporous CND materials had graphitic-like structures and consisted of CN heterocycles, as well as amino groups. In a series of Knoevenagel condensation reactions, as exemplified by the reaction of various aldehydes and nitriles, these mesoporous CND materials demonstrated high and stable catalytic activities, owing to an abundance of basic sites.