简体   繁体   English

将按钮控件动态添加到ASP.NET页的最有效方法是什么

[英]What is the most efficient way to dynamically add button controls to ASP.NET page

I've created a ASP.NET website and on page load I have to dynamically add button controls(80 to 500). 我已经创建了一个ASP.NET网站,并且在页面加载时必须动态添加按钮控件(80到500)。 When I add more than 40 buttons it takes a little bit of time for the page to load. 当我添加40多个按钮时,页面加载需要一点时间。 So my question is: What is the best way to dynamically add button controls to ASP.NET web form without losing performance? 所以我的问题是:在不损失性能的情况下向ASP.NET Web表单动态添加按钮控件的最佳方法是什么?

Thank you. 谢谢。

The most efficient way would be Controls.Add(..). 最有效的方法是Controls.Add(..)。 However, its likely rendering time here is your bottleneck - which is not strictly and ASP.net issue. 但是,这里可能的渲染时间是您的瓶颈-严格来说,这不是ASP.net的问题。 Adding controls to an ASP.net control collection is super fast. 将控件添加到ASP.net控件集合非常快速。

Albeit, 500 buttons on a given page seems excessive. 尽管在给定页面上有500个按钮似乎过多。 You should probably look at a paging solution to get better performance. 您可能应该看一下分页解决方案以获得更好的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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