web-user-controls

When to enable/disable Viewstate

China☆狼群 提交于 2019-11-30 22:09:49
问题 I generaly disable viewstate for my ASP.net controls unless I explicitly know I am going to require view state for them. I have found that this can significantly reduce the page size of the HTML generated. Is this good practice? When should be enabled or disabled? 回答1: Yes it is a very good idea. One could argue that it should have been disabled by default by Microsoft, just like caching. To see how bad Viewstate is in terms of size increased you can use a tool called Viewstate Analyzer. This

Dynamically added controls in Asp.Net

十年热恋 提交于 2019-11-27 06:50:54
I'm trying to wrap my head around asp.net. I have a background as a long time php developer, but I'm now facing the task of learning asp.net and I'm having some trouble with it. It might very well be because I'm trying to force the framework into something it is not intended for - so I'd like to learn how to do it "the right way". :-) My problem is how to add controls to a page programmatically at runtime. As far as I can figure out you need to create the controls at page_init as they otherwise disappears at the next PostBack. But many times I'm facing the problem that I don't know which

Passing int array as parameter in web user control

蹲街弑〆低调 提交于 2019-11-27 02:06:35
问题 I have an int array as a property of a Web User Control. I'd like to set that property inline if possible using the following syntax: <uc1:mycontrol runat="server" myintarray="1,2,3" /> This will fail at runtime because it will be expecting an actual int array, but a string is being passed instead. I can make myintarray a string and parse it in the setter, but I was wondering if there was a more elegant solution. 回答1: Implement a type converter, here is one, warning : quick&dirty, not for

Dynamically added controls in Asp.Net

瘦欲@ 提交于 2019-11-26 12:12:42
问题 I\'m trying to wrap my head around asp.net. I have a background as a long time php developer, but I\'m now facing the task of learning asp.net and I\'m having some trouble with it. It might very well be because I\'m trying to force the framework into something it is not intended for - so I\'d like to learn how to do it \"the right way\". :-) My problem is how to add controls to a page programmatically at runtime. As far as I can figure out you need to create the controls at page_init as they