tag:blogger.com,1999:blog-6958775774153114698.post8315287960648848345..comments2011-03-03T13:04:50.380-05:00Comments on Getting to Know Sitecore: Sublayouts and Web ControlsAnonymoushttp://www.blogger.com/profile/17553102841662581042noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6958775774153114698.post-63474335425398255272011-02-01T08:40:25.594-05:002011-02-01T08:40:25.594-05:00I have a question regarding this topic. We have c...I have a question regarding this topic. We have certain items stored in our proprietary databases that we need to grab and display to users in Sitecore sites. We have built a webcontrol (or series of) to handle this.<br /><br />What is the difference between dropping these controls into a layout/sublayout withouth adding them to Sitecore versus putting them in the sitecore Layout/Renderings folder?<br /><br />Also, since this data has nothing to do with Sitecore and simply returns a list of items to be displayed in some sort of grid/table etc, what would be the benefit of inheriting Sitecore. I guess what I'm really asking is what extra advantages do you get by inheriting Sitecore?<br /><br />Thanks,<br />RMAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6958775774153114698.post-6740355858301231022010-12-07T14:51:51.314-05:002010-12-07T14:51:51.314-05:00Hi Adam,
I enjoy reading your post. So based on m...Hi Adam,<br /><br />I enjoy reading your post. So based on my understand that the components of a sublayout is .NET web user control file and not a .net web form file.<br /><br />Antony.Antonyhttp://www.ottawa.canoreply@blogger.comtag:blogger.com,1999:blog-6958775774153114698.post-38331500529027311312010-03-10T08:30:47.041-05:002010-03-10T08:30:47.041-05:00Hi Steve. I don't think the decision to use w...Hi Steve. I don't think the decision to use web controls or sublayouts is really any different than the decision to use web controls or user controls in a regular ASP.NET site. <br /><br />As far as there being any specific Sitecore advantage to choosing one or the other, one thing that comes to mind is that with web controls you extend Sitecore.Web.UI.WebControl. This provides easy access to some values that might be hard to get to from a user control. But I think this advantage is only relevant in certain highly specialized cases.Anonymoushttps://www.blogger.com/profile/17553102841662581042noreply@blogger.comtag:blogger.com,1999:blog-6958775774153114698.post-91326004948959235512010-03-07T12:51:41.079-05:002010-03-07T12:51:41.079-05:00Really enjoying the blog so far Adam, its really h...Really enjoying the blog so far Adam, its really helping me fully understand some of the fundamentals after training last week. Quick question though. <br /><br />Is there anything to be lost if you do not use renderings (WebControls) and just stick to nested SubLayouts (UserControls)? Im personnely not a great fan of UserControls as you usually end up with HTML in code which confuses the CSS team!Fred Bloggshttps://www.blogger.com/profile/16600374227448065798noreply@blogger.comtag:blogger.com,1999:blog-6958775774153114698.post-91188280316055036022010-02-03T07:33:06.141-05:002010-02-03T07:33:06.141-05:00And another comment on WebControls, if you want to...And another comment on WebControls, if you want to use Sitecore Caching on them, make sure to inherit from Sitecore.Web.UI.WebControl and override GetCachingID() method.<br />No need to do anything with Sublayouts, though.Raul Jimeneznoreply@blogger.comtag:blogger.com,1999:blog-6958775774153114698.post-84906549039778279202010-02-03T03:14:24.871-05:002010-02-03T03:14:24.871-05:00Thanks for the feedback, Seth. One thing about we...Thanks for the feedback, Seth. One thing about web controls, though. I think a better way for me to have explained it is to say that even though you don't _have_ to, you _want_ to extend Sitecore.Web.UI.WebControl.<br /><br />By extending Sitecore.Web.UI.WebControl you get extra functionality, like what you described. Using a web control inside Sitecore without this functionality in most cases probably doesn't make a lot of sense. Surely you're not taking advantages of the strengths of the product this way.<br /><br />But Sitecore doesn't prevent you from using a web control that inherits from System.Web.UI.WebControls.WebControl. <br /><br />I think this is a good thing. This could be useful is you have a web control that doesn't interact with Sitecore. For example, a web control that monitors site traffic or one that generates ads. <br /><br />Granted, neither of those is the best example because both could benefit by interacting with Sitecore, but hopefully you get the idea!Anonymoushttps://www.blogger.com/profile/17553102841662581042noreply@blogger.comtag:blogger.com,1999:blog-6958775774153114698.post-78662045607578025402010-02-02T18:20:25.313-05:002010-02-02T18:20:25.313-05:00Nice post, Adam. I'm really enjoying reading y...Nice post, Adam. I'm really enjoying reading you Getting to Know Sitecore blog!<br /><br />I just want to make a few comments about Web Control items and classes in Sitecore.<br /><br />If you want your Web Control to be a Sitecore Web Control, the class needs to inherit from Sitecore.Web.UI.WebControl. There are many reasons for this, like getting access to control parameters, etc. Remember to override the DoRender() method. <br /><br />You can use the Sitecore Developer Center to create the Web Control definition item, or, just like in your video, select an insert option to create the definition item. <br /><br />Some people may be scratching their heads and asking "Where do I do this? There is no WebControls folder item, but there is a Sublayout item"<br /><br />You'll find the option in the Renderings item (path is"/sitecore/Layout/Rendering/").<br />In the dialog, enter the name of the control. There are many fields to edit here, but I'll just focus on the important ones. I'll leave the blogging on this topic to you :-)<br /><br /><b>The Editor Options field Section</b><br />Description Field: Always enter a description, even use screenshots. In Page Editor Design Pane, business users will see this Rich Text Description.<br /><br /><b>The Data Field Section</b><br />Namespace: This is the namespace of the control. Copy it verbatim from visual studio. Do NOT type it in.<br><br />Tag: This is the Class name of the control. Copy it verbatim from visual studio. Do NOT type it in.<br><br />TagPrefix: Whatever you want it to be. Usually, we see a company tag prefix, like "og" or “pop”. Do NOT use sc, as this is for out-of-the-box Sitecore Web Controls.<br><br />Assembly: This is usually the assembly name for the project. Copy it verbatim from visual studio. Do NOT type it in.<br /><br><br />Once you have created your definition item, you’re ready to go. For example, you’ll be it able to dynamically add the control to a placeholder using Page Editor Design Pane.<br /><br />Lastly, always remember to compile your control!Sethhttp://www.sitecore.netnoreply@blogger.com