In situ formed nanomaterials for colorimetric and fluorescent sensing