简体   繁体   中英

How to keep the class of a ASP textbox on partial postback

I was hoping the JQuery script will ensure any textbox which isn't readonly will apply update to the class but that is not happening and also the alert isn't even being displayed. I am thinking it is because the textboxes are inside an updatepanel?

How can I keep the state of the textbox so if it had the colorRed class, it remains with that after a partial postback.

You can change the CssClass in the server instead of using JS; You can also change the logic to watch the parent element and change the class of each textbox.. according with the ReadOnly attribute, for example. $(document).on("change", "#upPerson", function(){ $("input[readonly=true]").removeClass("colorBlue").addClass("colorRed"); }); I did not test anything, but that's the logic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM