Kev siv ModelState hauv MVC yog dab tsi?
Kev siv ModelState hauv MVC yog dab tsi?

Video: Kev siv ModelState hauv MVC yog dab tsi?

Video: Kev siv ModelState hauv MVC yog dab tsi?
Video: looj phaj kev siv 2024, Kaum ib hlis
Anonim

Mvc . Tus tswj. Cov ModelState sawv cev rau ib phau ntawm lub npe thiab tus nqi khub uas tau xa mus rau lub server thaum lub sijhawm POST. Nws kuj muaj ib phau ntawm cov lus yuam kev rau txhua tus nqi xa.

Ib yam li ntawd, kev siv ModelState IsValid hauv MVC yog dab tsi?

ModelState . Yog siv tau qhia rau koj yog tias muaj qauv yuam kev tau ntxiv rau ModelState . Lub neej ntawd qauv binder yuav ntxiv qee qhov yuam kev rau hom kev hloov pauv yooj yim teeb meem (piv txwv li, dhau tus lej tsis yog rau qee yam uas yog "int"). Koj muaj peev xwm populate ModelState ntau tag nrho raws li qhov kev lees paub qhov system uas koj siv.

Kuj Paub, dab tsi yog lub xeev qauv hauv asp net? A ModelState yog ib phau ntawm lub npe thiab tus nqi khub xa mus rau tus neeg rau zaub mov thaum lub sijhawm thov POST. Nws kuj muaj ib phau ntawm cov lus yuam kev rau txhua tus nqi. Cov Modelstate sawv cev rau validation yuam kev nyob rau hauv xa HTML daim ntawv muaj nuj nqis.

Ib yam li ntawd, nws tau nug, lub ntsiab lus ntawm ModelState IsValid yog dab tsi?

ModelState . Yog siv tau qhia tau hais tias nws muaj peev xwm los khi cov txiaj ntsig tau los ntawm qhov kev thov mus rau qauv kom raug thiab seb puas muaj cov cai qhia meej meej txog kev lees paub tau tawg thaum lub sijhawm qauv kev khi txoj kev. Hauv koj qhov piv txwv, tus qauv uas raug khi yog ntawm chav kawm hom Encaissement.

Muaj pes tsawg hom kev lees paub muaj nyob hauv MVC?

ob

Pom zoo: