Is there any way to use a specific usercontrols depending on which theme the site is using?
Scenario:
I am using themes in my asp.net project. I am going to have same codebase and different look and feel and so using themes & skins.
Now the problem is if I want to have different headers & footers (which are usercontrols) depending on the type of site, how can we do with the help of themes.
Yes, control hierarchies can be modified with themes.
This is made possible by ITemplate properties that are Themeable.
If, for instance, you had a custom control that simply has a themeable Contents property you could say:
<custom:MyThemeableControl runat="server">
<Contents>
... any valid *.skin markup here
</Contents>
</custom:MyThemeableControl>
Now you could swap out the controls inside Contents for different themes as follows - for ThemeA you would have the following skin:
<custom:MyThemeableControl runat="server">
<Contents>
<asp:Button runnat="server" />
</Contents>
</custom:MyThemeableControl>
And for ThemeB you would have the following skin:
<custom:MyThemeableControl runat="server">
<Contents>
<asp:TextBox runnat="server" />
</Contents>
</custom:MyThemeableControl>
Then this page would render a Button under ThemeA and a TextBox under ThemeB:
<#Page Theme="ThemeA">
<custom:MyThemeableControl runat="server" />
<#Page Theme="ThemeB">
<custom:MyThemeableControl runat="server" />
Related
I can't find the source code for the html used for the calendar table. I have the webpart, but not the html for the table. I need to strip the inline CSS and attributes.
Following is the markup for the event calendar (obviously this is what you see):
<%# Control Language="C#" AutoEventWireup="true"
Inherits="CMSWebParts_EventManager_EventCalendar" CodeFile="~/CMSWebParts/EventManager/EventCalendar.ascx.cs" %>
<div class="Calendar">
<cms:CMSCalendar ID="calItems" runat="server" EnableViewState="false" />
</div>
<div class="EventDetail">
<cms:CMSRepeater ID="repEvent" runat="server" Visible="false" StopProcessing="true" EnableViewState="false" />
</div>
So what you see on the live page is created by CMSCalendar control, which leaves in CMS.Controls library, which means you can't modify it unless you have full source code of Kentico.
I'd try to change the appearance of this control with CSS, if CSS doesn't work there is javascript/jQuery.
Have you looked into creating a skin? You can change the css classes used if needed.
Might help some
I have some Styles-Files.
For example ButtonStyles.xaml looks like this:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style
x:Key="CustomButtonStyle"
TargetType="Button">
<Setter
Property="Foreground"
Value="White" />
<Setter
Property="Background"
Value="Black" />
<Setter
Property="Height"
Value="32" />
</Style>
<Style
TargetType="Button"
BasedOn="{StaticResource CustomButtonStyle}">
</Style>
</ResourceDictionary>
And I have Pages which extend from my BasePage.
If I want my new Styles to override the controls I have to add this Code in every Page:
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Styles/ButtonStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
However if I have this code in my BasePage it won't theme my controls.
Is there a way to import my styles in every Page without copy-pasting this code over and over?
I can't reproduce this issue with using BasePage in my side. It would be better if you can post a sample that can reproduce your issue.
However, to use the custom styles in every page, I recommend merging resource dictionaries into Application.Resources. Application.Resources is the best place to put any app-specific resources that are referenced by multiple pages in your app's navigation structure. If the requested resource is not found in the Page.Resources, the XAML resources system will tries to check the Application.Resources property. So if we merged resource dictionaries into Application.Resources, we can use them in all pages of the app. And if we want to use some different styles in certain pages, we can specify new Style in their Page.Resources. For more information, see Lookup behavior for XAML resource references.
So we can merge resource dictionaries into Application.Resources like following:
(Note that ../Styles/ButtonStyles.xaml can't be used in WinRT XAML, we should use "/" to refer to the package root.)
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Styles/ButtonStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Then in other pages, if we don't specify the Style for Button, it will use the style defined in ButtonStyles.xaml.
I have a requirement to display SharePoint fields as a footer on only certain pages, so this rules out a master page change, and I haven't had any success with plain-old HTML.
What I'm trying to display is the following code:
<SharePoint:DeveloperDashboard runat="server"/>
<div class="s4-notdlg" style="clear:both; background-color:orange; padding:10px">
<SharePoint:CreatedModifiedInfo ControlMode="Display" runat="server">
<CustomTemplate>
<br>Page Contact: <SharePoint:FormField FieldName="Page Contact" runat="server" ControlMode="Display" DisableInputFieldLabel="True" />
<br>Last modified on <SharePoint:FieldValue FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="True" />
by <SharePoint:FormField FieldName="Author" runat="server" ControlMode="Display" DisableInputFieldLabel="True" />
<br>Comments: <SharePoint:FormField FieldName="Check In Comment" runat="server" ControlMode="Display" DisableInputFieldLabel="True" />
</CustomTemplate>
</SharePoint:CreatedModifiedInfo>
</div>
When editing the page in Advanced Mode, no matter where I place the code, I break site definition. Is there a good place to insert this code in the page? Or does the Site Definition need to be changed.
Breaking the Site Definition may not be what you are thinking. It is just saying to you that the page is not one of the 'defaults' anymore, as a way to identify what have been customized on the site.
Every edit you make on those pages are like that, so it is OK to get that message. You may also "reset to site definition" when you want to, but this is not usually very stable on my experience.
I have copied C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\EventsList\Events\schema.xml into a custom list template feature. I have another feature that creates the list instance:
<ListInstance
FeatureId="58c1f9c9-eadb-41dd-a358-e04b2f2e30c0"
TemplateType="100322"
Title="$Resources:core,calendarList"
Url="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder"
OnQuickLaunch="TRUE">
</ListInstance>
and then places a ListViewWebPart on the page:
<View List="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder" BaseViewID="0" WebPartZoneID="TopRightRow" WebPartOrder="3" />
I activate the features and go to the site. The webpart says: There are currently no upcoming events. To add a new event, click "Add new event". I click Add new event, enter the information, and click Save. The page refreshes, the no upcoming events message disappears, but there are no items displayed! If I go to the calendar the list item is there. What gives?
I change the list instance definition so that it uses the out of the box template:
<ListInstance
FeatureId="00bfea71-ec85-4903-972d-ebe475780106"
TemplateType="106
Title="$Resources:core,calendarList"
Url="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder"
OnQuickLaunch="TRUE">
</ListInstance>
When I rebuild the site, activate the features, and repeat the "add new" steps, the item is now displaying properly in the webpart after the page refresh.
I've backed out all of my changes from the custom list template. It is now identical to the OOTB schema. Why doesn't my custom list template work, but the OOTB list template does?
I have know idea why the OOTB template works, but I was able to fix my custom template.
First, remove the XslLink line from the BaseViewID="0" View in schema.xml:
<XslLink>main.xsl</XslLink>
Scroll down to the Toolbar/IfHasRights section. Change Case 4 from:
<Case Value="4"><HTML><![CDATA[<div class="tb"><img src="/_layouts/images/caladd.gif" alt="" /> <a class="ms-addnew" id="idHomePageNewEvent" href="]]></HTML>
<URL Cmd="New" /><HTML><![CDATA[" onclick="javascript:NewItem(']]></HTML>
<ScriptQuote NotAddingQuote="TRUE">
<URL Cmd="New" />
</ScriptQuote><HTML><![CDATA[', true);javascript:return false;" target="_self">]]></HTML><HTML>$Resources:core,AddNewEvent;</HTML><HTML><![CDATA[</a></div>]]></HTML>
</Case>
to:
<Case Value="4"><HTML><![CDATA[<div class="tb"><img src="/_layouts/images/caladd.gif" alt="" /> <a class="ms-addnew" id="idHomePageNewEvent" href="]]></HTML>
<URL Cmd="New" /><HTML><![CDATA[" onclick="javascript:NewItem2(event, ']]></HTML>
<ScriptQuote NotAddingQuote="TRUE">
<URL Cmd="New" />
</ScriptQuote><HTML><![CDATA[');javascript:return false;" target="_self">]]></HTML><HTML>$Resources:core,AddNewEvent;</HTML><HTML><![CDATA[</a></div>]]></HTML>
</Case>
This enables the new SharePoint 2010 popup NewForm.aspx behavior.
Next, change the provisioning of the webpart to:
<View List="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder" BaseViewID="0" WebPartZoneID="TopRightRow" WebPartOrder="3">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
<Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
<Title>Calendar</Title>
</WebPart>
]]>
</View>
This along with the removal of the XslLink line forces the webpart to render as a ListViewWebPart instead of as an XsltListViewWebPart.
Now the rendering between the two weparts is different, so as a last step, use the following style so that the add new link of the ListViewWebPart looks like the add new link of the XsltListViewWebPart:
div.tb {
border-top:1px solid #EBEBEB;
margin:3px 0 16px;
padding:9px 7px 3px 10px;
}
I have a custom masterpage in sharepoint and want to output the site title in a different part of the page. Currently I can see the site title which is outputted using the following code:
<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" Visible="true" />
Apparently using
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" Visible="true" />
Should also output the title but is returning nothing. Any ideas what is going wrong?
The Code you have mentioned are the Content Place Holders where you can replace the Content, You can place the register the below tag in the top the page and
<%# Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
And place the below code to get the Title of the Page
<SharePoint:ProjectProperty Property="Title" runat="server" />
If you want to do that in the master page level you can do with the below code
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" Visible="true">
<SharePoint:ProjectProperty Property="Title" runat="server" />
</asp:ContentPlaceHolder>
Unless you override the above content place holder you will get the Title of the Web Automatically
This can be done by using the ProjectProperty control (see http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.projectproperty.aspx)
<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server">
<SharePoint:ProjectProperty property="Title" runat="server" />
</asp:ContentPlaceHolder>