<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Cristiano WebLog : Visual Studio 2005</title><link>http://blogs.msdn.com/crisag/archive/tags/Visual+Studio+2005/default.aspx</link><description>Tags: Visual Studio 2005</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>The Page Appearance Framework.</title><link>http://blogs.msdn.com/crisag/archive/2006/10/03/The-Page-Appearance-Framework_2E00_.aspx</link><pubDate>Tue, 03 Oct 2006 22:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:787690</guid><dc:creator>crisag</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/crisag/comments/787690.aspx</comments><wfw:commentRss>http://blogs.msdn.com/crisag/commentrss.aspx?PostID=787690</wfw:commentRss><wfw:comment>http://blogs.msdn.com/crisag/rsscomments.aspx?PostID=787690</wfw:comment><description>&lt;P&gt;Are you curious on how to control the appearance of an ASP .Net pages using design time properties? Guys from Commerce Server team have shown how to deal with this problem. On a preliminary version of the CS2007 Starter Site (that one with came with CS2007 Beta) they use class properties to deal with the appearance of the sample store page framework.&lt;/P&gt;
&lt;P&gt;First step is create a new masterpage with a set of DIV files that can be enabled or disabled according with different page layout statuses.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The second step is create a base class with a property to control the presentation&lt;/P&gt;
&lt;P&gt;public abstract class SiteMasterPage : System.Web.UI.MasterPage&lt;BR&gt;{&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;•&amp;nbsp;Layout property: Control the appearance of the DIV areas inside the masterpage. Depending on context, the background code can change the layout of the page.&lt;/P&gt;
&lt;P&gt;Now you need to create a new masterpage and insert code to deal with the properties:&lt;/P&gt;
&lt;P&gt;•&amp;nbsp;OnPreRender event: Deal with layout. Activating or deactivating DIVs according to the Layout properties&lt;/P&gt;
&lt;P&gt;protected override void OnPreRender(EventArgs e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;switch (this.LayoutStyle)&lt;BR&gt;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;//se for mínimo, remove o banner, os sidebars, o menu e o rodapé. &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // deixa só o mainpagecontent&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case PageLayoutStyle.Minimal:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.adbanner.Visible = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.sidebar_a.Visible = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.sidebar_b.Visible = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.footer.Visible = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.menu.Visible = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;BR&gt;&amp;nbsp;&amp;nbsp;case PageLayoutStyle.Full:&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.adbanner.Visible = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.sidebar_a.Visible = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.sidebar_b.Visible = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.footer.Visible = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.menu.Visible = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.Page.Title = this.title; //ajusta o título da página&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; base.OnPreRender(e); //executa a base do prerender&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;To get the design time class properties you can use a piece of code like the following one:&lt;/P&gt;
&lt;P&gt;settings = PageSettings.GetPageSettings(HttpContext.Current.CurrentHandler.GetType());&lt;/P&gt;
&lt;P&gt;internal static PageSettings GetPageSettings(Type type)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (type == null)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new ArgumentNullException("type");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!type.IsSubclassOf(typeof(Page)))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new ArgumentException("SubClass", "type");&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!PageSettings.typeCache.ContainsKey(type))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lock(typeCache)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Não está em cache, temos que popular.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!PageSettings.typeCache.ContainsKey(type))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string pageGroup = null;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool isSecure = false;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PageLayoutStyle layoutStyle = PageLayoutStyle.Full;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; object[] attributes = type.GetCustomAttributes(true);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (Attribute attribute in attributes)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (typeof(PageLayoutAttribute).IsInstanceOfType(attribute))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layoutStyle = ((PageLayoutAttribute)attribute).LayoutStyle;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PageSettings.typeCache.Add(type, new PageSettings(layoutStyle, isSecure, pageGroup));&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return PageSettings.typeCache[type];&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;At design time, we just need to tell how the page will look using the following approach:&lt;/P&gt;
&lt;P&gt;[PageLayout(PageLayoutStyle.Full)]&lt;BR&gt;public partial class _Default : System.Web.UI.Page&lt;BR&gt;{&lt;BR&gt;…&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;Remember that your ASPX page must be based on a MasterPage created from the custom base class.&lt;/P&gt;
&lt;P&gt;public partial class StandardLayout : SiteMasterPage&lt;BR&gt;{&lt;BR&gt;...&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;Regards, Cris.&lt;BR&gt;&lt;SPAN minmax_bound="true" deactivatedstyle="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'MS Mincho'; mso-ansi-language: EN-US; mso-fareast-language: JA; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Verdana size=3 minmax_bound="true"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN minmax_bound="true" deactivatedstyle="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'MS Mincho'; mso-ansi-language: EN-US; mso-fareast-language: JA; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Verdana size=3 minmax_bound="true"&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR minmax_bound="true"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=787690" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/crisag/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category></item><item><title>The Visual Studio 2005 Code-Beside Dilemma!</title><link>http://blogs.msdn.com/crisag/archive/2006/09/29/The-Visual-Studio-2005-Code_2D00_Beside-Dilemma_2100_.aspx</link><pubDate>Fri, 29 Sep 2006 16:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:776918</guid><dc:creator>crisag</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/crisag/comments/776918.aspx</comments><wfw:commentRss>http://blogs.msdn.com/crisag/commentrss.aspx?PostID=776918</wfw:commentRss><wfw:comment>http://blogs.msdn.com/crisag/rsscomments.aspx?PostID=776918</wfw:comment><description>&lt;P&gt;Did you know that? With Visual Studio 2003 we were able to extend the System.Web.UI.Page class and create new properties for WebForms. Test yourself, using VS2003, create a new property for your class (derived from System.Web.UI.Page), create a new ASP .Net page based on your new class and you will see the created property it on the Visual Studio properties page for the ASPX.&lt;/P&gt;
&lt;P&gt;When saving the page, you will see that the code behind is automatically changed to include the property values. It is a very easy approach to create custom properties on ASP .Net web pages.&lt;/P&gt;
&lt;P&gt;A couple of weeks ago I was working with one of our customers and I said that he could use the properties approach to easily customize the appearance of his ASP .Net web pages. But what’s my surprise when I noticed that this is not working on Visual Studio 2005.&lt;/P&gt;
&lt;P&gt;Ok. Know the reason for such thing not work anymore became a question of honor. After post some questions on our internal lists and search a little bit on the Internet I figured out the reason.&lt;/P&gt;
&lt;P&gt;Before begin the explanation, I’d like to let you know that it is a known issue reported at &lt;A href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105510" mce_href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105510"&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105510&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Let’s try to explain.&lt;/P&gt;
&lt;P&gt;According to my research there was a design change in the product. Basically in Visual Studio 2005 RTM, the code behind file and the generated stub are compiled into the base class, and the actual ASP .Net page inherits the base class. &lt;/P&gt;
&lt;P&gt;The V1.X code behind model (seen on the Visual Studio 2003) is still supported by the runtime, however, you cannot use Visual Studio 2005 for editing the V1.X style pages.&lt;BR&gt;&amp;nbsp;&lt;BR&gt;The code that was being generated by Visual Studio 2003 IDE is now moved to the partial class that is automatically generated during compilation. If you just want to see what is in the generated class, you can set the page to debug mode and look for the generated files under the ASP.NET temporary folder.&lt;/P&gt;
&lt;P&gt;The model is changed to allow updatable pages after compilation. To achieve this, the product group came up with the current model which is very similar to V1.X that the codes behind files are still compiled into the base classes. The only difference is that the control field declarations and the class constructor are now automatically generated instead of injected at design time. &lt;/P&gt;
&lt;P&gt;So the collateral effect appeared. As the control field declarations are automatically generated at the compilation time we cannot store the adjusted values for custom properties on the appropriate place. Therefore we need a different approach to implement this kind of functionality.&lt;/P&gt;
&lt;P&gt;I managed to implement (with the help of a sort of samples) a mechanism that can be used to coordinate the appearance of ASP .Net pages at design time using class properties injected manually on the code. I’ll show how to do that on another post. Stay tuned!&lt;/P&gt;
&lt;P&gt;Bye!!&lt;/P&gt;
&lt;P&gt;&lt;SPAN minmax_bound="true" deactivatedstyle="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'MS Mincho'; mso-ansi-language: EN-US; mso-fareast-language: JA; mso-bidi-language: AR-SA"&gt;&lt;FONT face=Verdana size=3 minmax_bound="true"&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR minmax_bound="true"&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=776918" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/crisag/archive/tags/Visual+Studio+2005/default.aspx">Visual Studio 2005</category></item></channel></rss>