There is provided a method for the preparation of an N,N,N-trialkylaminopolymer having one or more unsubstituted heteroatoms different from nitrogen atom. The method comprises a first step of alkylating an aminopolymer to produce an N,N-dialkylaminopolymer, wherein substantially no N,N,N- trialkylaminopolymer is produced; and a second step of alkylating the N,N-diaminopolymer to produce the N,N,N-trialkylaminopolymer. The N,N,N-trialkylaminopolymer is produced with a satisfactory degree of quaternization and with only a low percentage of the unsubstituted heteroatoms alkylated. The N,N,N- trialkylaminopolymer can be an N,N,N-trialkylaminopolysaccharide or an N,N,N-trialkylchitosan such as N,N,N-trimethylchitosan.