简体   繁体   中英

pros and cons, using literal control vs exact control and runat=server

We've run into some scenarios brought about by our CMS system where we can't use code blocks anymore. There is currently some discussion about whether to use literal controls vs using the exact control needed and modifying the inner html, href, innerText... etc.

For some reason I hate literal controls, but can't really explain why other than I hate building html on the server side.

The main advantage of the Literal is that it does not render additional tags - it only displays what has been assigned to the Text property. So its useful to quickly display HTML or JavaScript.

However the disadvantage of using these Literal controls is that it gets messy when you want further programmatic control over the control - eg have styling on the Text that is outputted (you can do it with Literals but it is ugly)

Refer to this:

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