This article reports the synthesis of new Dye A from the reaction of 4-methyl 2-nitroaniline, NaNO2/H+, and sodium 1-naphtholate. Dye A responded with an obvious colour change visible to naked eyes to pH, ultraviolet light, and fluoride ion and was studied by UV-vis spectroscopy. Next, the reaction of Dye A with crotonic anhydride leads to the formation of MDye A. Subsequently, synthesis of a new type of photochromic and pH-sensitive colorimetric hydrogel consisting of a new azobenzene (MDye A), acrylic acid, acrylamide, N,N'-methylenebisacrylic amide as a crosslinking agent, and sodium acrylate in the presence of 2,2'-azobis(isobutyronitrile) as initiator and sorbitan monostearate (Span 60) as the dispersant or under a LED lamp (400 nm, 20 W) in the presence of CdS nanorods and beta-cyclodextrin was studied. The products were characterized using H-1 NMR,C-13 NMR, TGA, DTG, SEM, TEM, and FTIR spectroscopy. The synthesized new hydrogel showed good pH responsiveness and photoresponsiveness, which was investigated by UV-vis spectroscopy. Also, the effects of parameters such as amounts of CdS nanorods, cross-linker, and water, duration of pre-oxygenation, light intensity on the swelling of gel, and polymerization rate in the synthesis of hydrogel were investigated.