简体   繁体   中英

How to keep the state of dynamic controls in ASP.NET?

I am creating some dynamic textboxes through javascript, when postback is happening i am loosing the controls. I can't use Ajax instead of postback and i can't create dynamic controls from code behind.

Can anyone please give any suggestion about it?

If you create controls on client in javascript they will not be created for you on server side because server side doesn't know about them. If you want data posted from these controls you can access them by Request.Form collection.

Can you not just create the textboxes server side, and show/hide via javascript/CSS? This prevents javascript doing any creating of controls and concentrates on the correct displaying of the user interface. The server knows all the controls on the page, and can deal with the business logic appropriately.

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