Reasons to remove ID's from Controls in on pag

2019-09-08 06:33发布

It is possible to remove ID's from pages being renedered in .NET. This can be done by simply setting the ID tag of an element with the attribute runat="server" to null. Obviously this shouldn't be done for controls that have to be evaluated / used on postback scenarios. I am very curious on how widely removing ID's will be used by people knowing this can be done. I know that by removing ID values you are able to save some bandwith, but what should be a reason to start using this method?

1条回答
Summer. ? 凉城
2楼-- · 2019-09-08 07:18

If you're really concerned with performance I'd perhaps worry less about the verboseness of the .NET control IDs (which is a real pet dislike of mine) and worry more about the overall postback model.

The whole send the state to the client so that it can post it pack to the server is woefully inefficient in both latency and bandwidth terms.

If it's a new project it's probably worth use MVC instead, or if it's existing try turning page compression on in IIS.

查看更多
登录 后发表回答