从页面控件中删除 ID 的原因
可以从 .NET 中重新渲染的页面中删除 ID。只需将属性 runat="server" 的元素的 ID 标记设置为 null 即可完成此操作。显然,对于必须在回发场景中评估/使用的控件,不应该这样做。我很好奇知道可以做到这一点的人们将如何广泛地使用删除 ID。我知道通过删除 ID 值可以节省一些带宽,但是开始使用此方法的理由是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您真的关心性能,我可能不太担心 .NET 控件 ID 的冗长(这是我真正不喜欢的),而是更担心整体回发模型。
将状态发送到客户端以便客户端将其包发布到服务器的整个过程在延迟和带宽方面都是非常低效的。
如果它是一个新项目,则可能值得使用 MVC,或者如果它是现有项目,请尝试在 IIS 中打开页面压缩。
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.