Last post May 09, 2009 06:24 AM by joteke
May 08, 2009 10:55 AM|deap82|LINK
I'm thinking about making a control that inherits from PlaceHolder. Based on some condition the controls content shoult not be rendered, is Render a good place for doing this? What will happen if my CustomPlaceHolder contains a gridview that gets some data from
a db through a datasource, will that databinding occur even if the CustomPlaceHolder decides not to render it's contents?
render databinding placeholder
May 09, 2009 12:30 AM|agrawalbs|LINK
dont add the controls (based on the condition) to the placeHolder if you dont want them to render.
if you add them to the place holder and just make visible=false, all the server side process will happen only the mark up will not be sent to the browser
May 09, 2009 04:31 AM|deap82|LINK
So what you're saying is that if I use my CustomPlaceHolder in aspx markup, add some stuff to it's contents with markup, there is no way for the CustomPlaceHolder control to stop BOTH the processing and rendering of its contents?
Does anyone know how the asp:LoginView control works, if it processes all its content templates and then just not renders them if they're not applicable it must be a highly unefficient control to use if the templates content are doing a lot of db accessing...
May 09, 2009 06:24 AM|joteke|LINK
Templates are implemented by using ITemplate interface and basically decided at by the containing control if they are instantiated or not - LognView probably checks some properties like Request.User.IsAuthenticated (which is populated based on if auth cookie
exists) and detects the correct flow of instantiation logic based on that . It has impact on if controls on those templates will be instantiated and added to the Controls collection.
Controls which are not part of the Controls collection won't be rendered, and controls which are in Controls collection and rendering something, can be prevented from rendering by turning their Visible property to false as was said, however these control
will do what they do normally as part of the Controls collection (live through the control lifecycle) so from performance perspective not having controls is better than having controls which do not redner anything..