Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Building Web Parts wth Different Layouts View modes: 
User avatar
Member
Member
Armysniper89 - 8/3/2010 6:07:40 PM
   
Building Web Parts wth Different Layouts
I have a website that has three different master pages, one for home, one for most content, and one for double wide (no right column) content. To help make it easier, I have created Web Parts for static HTML like the footer so that it can be used on each master page layout and only be changed in one place. When I did this everything was great. Then I noticed that there was a Layout tab on the Footer's web part properties. So I tried to monkey with it and create a secondary layout that was just a smaller version of the ASCX I created for my footer. Problem is that if I used the secondary layout, it throws errors. This is simple HTML that looks like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Footer.ascx.cs" Inherits="Footer" %>
<div class="nav nav1">
<a href="/">Home</a>
|
<a href="/About/Default.aspx">About Us</a>
|
<a href="/About/Default.aspx?id=1016">Services</a>
|
<a href="/ContentLibrary/Listing.aspx?Resource=Articles">Articles</a>
|
<a href="/ContentLibrary/Listing.aspx?Resource=Case Studies">Case Studies</a>
|
<a href="/ContentLibrary/Listing.aspx?Resource=All">Content Library</a>
|
<a href="/MediaRoom/Default.aspx">Media Room</a>
|
<a href="/mediaroom/newsletterlisting.aspx?id=374">Newsletters & Alerts</a>
|
<a href="/RSS/Default.aspx">RSS Feed</a>
|
<a href="/Sitemap.aspx">Site Map</a>
|
<a href="/About/Default.aspx?id=824">Privacy Policy</a>
|
<a href="/About/Default.aspx?id=826">Terms of Use</a>
|
<a href="/About/ContactUs.aspx?id=60">Contact Us</a>
</div>
<div class="nav nav2">
<a href="/Careers/Default.aspx">Leadership</a>
|
<a href="/leadership-nonprofit-board-members.aspx">Board Members</a>
|
<a href="/leadership-nonprofit-coo.aspx">Chief Operating Officers</a>
|
<a href="/leadership-nonprofit-cfo.aspx">Chief Financial Officers</a>
|
<a href="/move-to-a-nonprofit-career.aspx">Move to a Nonprofit Career</a>
|
<a href="/careers-at-bridgespan.aspx">Current Jobs at Bridgespan</a>
|
<a href="/careers-at-bridgespan.aspx">Current Job Openings</a>
</div>
<div class="nav nav3">
<a href="/LearningCenter/Default.aspx?id=392&taxid=236">Build Our Organization</a>
|
<a href="/LearningCenter/Default.aspx?id=384&taxid=106">Develop a Strategy</a>
|
<a href="/LearningCenter/Default.aspx?id=388&taxid=232">Fund Our Mission</a>
|
<a href="/LearningCenter/Default.aspx?id=386&taxid=128">Manage Performance</a>
|
<a href="/LearningCenter/Default.aspx?id=394&taxid=238">Recruit Leaders</a>
|
<a href="/FieldsOfInterest/Default.aspx?id=998&taxid=152&parentID=152">Education</a>
|
<a href="/FieldsOfInterest/Default.aspx?id=990&taxid=154&parentID=154">Environment</a>
|
<a href="/LearningCenter/Default.aspx?id=390&taxid=234">Philanthropy</a>
|
<a href="/FieldsOfInterest/Default.aspx?id=992&taxid=156&parentID=156">Youth</a>
|
<a href="/FieldsOfInterest/Default.aspx?id=994&taxid=158&parentID=158">Other Fields</a>
</div>

I created a secondary layout that looked like this:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Footer.ascx.cs" Inherits="Footer" %>
<div class="nav nav1">
<a href="/">Home</a>
|
<a href="/About/Default.aspx">About Us</a>
|
<a href="/About/Default.aspx?id=1016">Services</a>
|
<a href="/ContentLibrary/Listing.aspx?Resource=Articles">Articles</a>
|
<a href="/ContentLibrary/Listing.aspx?Resource=Case Studies">Case Studies</a>
|
<a href="/ContentLibrary/Listing.aspx?Resource=All">Content Library</a>
|
<a href="/MediaRoom/Default.aspx">Media Room</a>
|
<a href="/mediaroom/newsletterlisting.aspx?id=374">Newsletters & Alerts</a>
|
<a href="/RSS/Default.aspx">RSS Feed</a>
|
<a href="/Sitemap.aspx">Site Map</a>
|
<a href="/About/Default.aspx?id=824">Privacy Policy</a>
|
<a href="/About/Default.aspx?id=826">Terms of Use</a>
|
<a href="/About/ContactUs.aspx?id=60">Contact Us</a>
</div>


What am I doing wrong? Can I use a layout for a web part this way or is it really for web parts that have server controls?

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/6/2010 1:10:57 AM
   
RE:Building Web Parts wth Different Layouts
Hi

It's important to keep all the controls in the layout. If you need to hide some of them, you can add Visible="False" attribute to the control, but the control must stay in the layout so that the web part keeps working.

For more info please read: http://devnet.kentico.com/docs/devguide/customizing_web_part_layout.htm?zoom_highlightsub=layout

Best regards,
Ivana Tomanickova

User avatar
Member
Member
Armysniper89 - 8/9/2010 1:52:27 PM
   
RE:Building Web Parts wth Different Layouts
Technically there are no controls in this...just raw HTML tags. I figured I could just have different smaller HTML segments.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/11/2010 9:54:58 AM
   
RE:Building Web Parts wth Different Layouts
Hi,

could you please post here your error message? Did you create your own webpart or did you use Static HTML webpart for your purposes.

In case of CS0115 error and your own webpart following steps should help.

1. Open the ASCX source file for the user control you have created.
2. On the first line please find the parameter CodeFile - here is the path to the code behind file. Please make this path to be relative, e.g. ~/CMSWebParts/MyFolder/MyWebPArt.ascx.cs
3. Now, please open the web part configuration and go to the Layout tab. On the first line change the path to the .cs file as mentioned in previous step.
4. Save the changes.

Best regards,
Ivana Tomanickova