PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Posts Tagged ‘UserControls’

Open SharePoint Link in a new Window

Posted by PANVEGA on October 12, 2008

In SharePoint when clicking on a link the windows opens in the same window as your application. However usually you still wanna have the link to your SharePoint Site. It’s definitely not the best user experience

Add the following JavaScript Code for example to your custom UserControl .ascx and add it to your Delegate Control in your master page:

Read more about Delegate Controls in my previous post

Read the rest of this entry »

Posted in Delegate Controls, JavaScript, MOSS, SPDesigner, UserControls | Tagged: , , , , | 4 Comments »

SharePoint Delegate Controls

Posted by PANVEGA on October 12, 2008

If you don´t wann add e.g. your JavaScript Link directly into your SharePoint Page <script type=”text/javascript” language=”javascript” src=”/Style Library/XSL Style Sheets/JS/ExpandGroup.js”></script> you should use the Delegate Controls and copy the JS Code in a new created ascx UserControl.

DelegateControl that you find in a lot of places in the master pages (especially the default.master). Essentially the Delegate Control provides an alternative to adding user controls and server controls to a .aspx page in the normal way.

Read the rest of this entry »

Posted in Delegate Controls, Deployment, MOSS, UserControls | Tagged: , , | 1 Comment »

Customize the VariationsLabelMenu UserControl

Posted by PANVEGA on August 6, 2008

The VariationLabelMenu.ascx UserControl gives you the oportunity to switch between the variations on your SharePoint Server. You find the Control in the 12er folder under Program Files~\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES” on your SharePoint 2007 Server. The master page associated with your site contains a small ASP.NET user control named VariationLabelsMenu.ascx that Office SharePoint Server 2007 displays on your pages (Picture), which allows a user to jump to the corresponding page in other variations.

default label menu

default label menu

By changing the value LabelMenuConfiguration in the tag <cms:VariationDataSource id=”LabelMenuDataSource” LabelMenuConfiguration=”2″ Filter=”” runat=”server” /> you can choose between different kind of menue layouts. When you are not satisfied with the possibilities, than add you custom CSS style sheet to the UserControl.

Sometimes you have to uncomment a specific line in the control <cms:VariationsLabelEcbMenu id =”varlabelmenu1″ DataSourceID=”LabelMenuDataSource” DisplayText=”<%$Resources:cms,VariationLabelMenuTitle%>” IsCallbackMode=”true” runat=”server” />.

Note:

By default the first language usually index[0] can not trigger when no index changed. Simple add the <asp:ListItem Selected=”True” Value=”Choose Country”/> in the asp:DropDownList and all variations trigger the redirection event to the specific site. In addition you have to set AutoPostBack=”true” to throw an event otherwise nothing happens.

You can hide variations from the navigation by clicking Modify Navigation Settings on the Site Settings page at the Site Collection Level.

Code:

<asp:DropDownList ID=”MyDropDown” DataSourceID=”LabelMenuDataSource”
AppendDataBoundItems=”true” DataValueField=”NavigateUrl” OnSelectedIndexChanged=”MyDropDown_OnSelectedIndexChanged” OnLoad=”MyInit” AutoPostBack=”true”
DataTextField=”Displaytext” runat=”server” CssClass=”variation” >
<asp:ListItem Selected=”True” Value=”Choose Country”/>
</asp:DropDownList>
<script type=”text/C#” runat=”server”>

protected void MyInit(object sender, EventArgs e)
{

PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(SPContext.Current.Web);
}

protected void MyDropDown_OnSelectedIndexChanged(object sender, EventArgs e)
{

Response.Redirect(MyDropDown.SelectedValue.ToString());
}
</script>

Note:

Before editing the control make a copy and gib´ve the custom control a new name. For example CustomVariationsLabelMenu.ascx and use it in your master page simply changing the register tag.

OLD <%@ Register TagPrefix=”PublishingVariations” TagName=”VariationsLabelMenu” src=”~/_controltemplates/VariationsLabelMenu.ascx” %>

NEW <%@ Register TagPrefix=”PublishingVariations” TagName=”CustomVariationsLabelMenu” src=”~/_controltemplates/CustomVariationsLabelMenu.ascx” %>

In the last step add the following tag <PublishingVariations:VariationsLabelMenu id=”labelmenu1″ runat=”server”/> in your masterpage to show the standard VariationsLabelMenu.

That ´s all you have to modify. Good luck.

Other Blogs:

http://sharepointxperience.blogspot.com/2008/02/accessible-variation-label-menu.html

http://msdn.microsoft.com/en-us/library/aa830817.aspx

Posted in MasterPage, MOSS, UserControls | Tagged: , , , | Leave a Comment »

Integrate an UserControl .ascx into a .aspx Page

Posted by PANVEGA on July 4, 2008

Introduction:

User controls provide a means by which custom graphical interfaces can be created and reused. A user control is essentially a component with a visual representation. As such, it might consist of one or more Windows Forms controls, components, or blocks of code that can extend functionality by validating user input, modifying display properties, or performing other tasks required by the author. Read the rest of this entry »

Posted in ASP.NET, DotNet, UserControls | Tagged: , , , | Leave a Comment »

VariationRootLandig redirect to another Variation Site

Posted by PANVEGA on May 15, 2008

Szenario:

When using the Variation in MOSS you have to manually redirect a user to a specific Sharepoint Variation language Site. When SharePoint is setup to use Variations, the root site collection is no longer used to store pages. Instead, you will have sub sites under the web root representing your variations. In my example I wan to redirect the user by his browsers local language settings. For example in Switzerland you find Italian, German and a Frenc speaking population. One of the variation Site is CH. The goal is to redirect users with fr-CH and it-CH to the Switzerland Variation Site. If MOSS does not find any personal language settings, the user wil be redirected to the default source site.

Important Note:

Notice that the labels are setup to use the culture-region format. YOu can find the list in your web browser sitteings e.g. [fr-CH ]. If you don’t follow this format, the variation logic will not be able to match the client language properly.

Introduction:

If you browse to the Variation home site, Office SharePoint Server 2007 looks up the WelcomePage property of the site and runs the VariationRoot page. Because that page is based on VariationRootPageLayout.aspx, it runs the page layout file. The VariationRootPageLayout page layout contains a reference to a file called VariationsRootLanding.ascx and one user control that is defined in the VariationsRootLanding.ascx file. The Page Layout executes the logic in the VariationsRootLanding.ascx file and redirects the user to a Variation site.

The root welcome page is configured by SharePoint (upon creation of variation labels and site structures) to point to a file called VariationRoot.aspx. This file contains a user control VariationsRootLanding.ascx, which has the code that redirects. The default behavior of the VariationsRootLanding.ascx is to detect the language setting of the client, and try to match it with one of the variation labels.

Read the rest of this entry »

Posted in MOSS, Uncategorized, UserControls | Tagged: , | Leave a Comment »

How to Add Actions to the User Interface?

Posted by PANVEGA on October 10, 2007

This example shows how to add custom actions to various menus in SharePoint through a Feature.

  1. Create a UserInterfaceCustomActions folder within the setup directory at the following location: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES.
  2. Create your custom feature.xml file in visual studio
  3. Create a elements.xml file with for example some CustomActions. Define here elements for the various actions included within the feature. For the sake of example, the URL for each action points to an .aspx file and passes it a value that identifies the source of the request. <UrlAction Url=”/_layouts/CustomHello.aspx?ViewToolbar”/>
  4. Create a aspx with custom example code CustomHello.aspx with some URL Parameters Queries and some text when the users clicks on the Hypetlink in the CustomAction string clientQuery = Page.Request.QueryString[“ListId”];
  5. Copy the file into the Layouts in the 12 MOSS Directory. Better using your Solution.
  6. Create also a UserControl file with some simple input CustomHello.ascx
  7. Copy the file into the ControlTemplates in the 12 MOSS Directory
  8. At a command prompt to install the Feature in the deployment, activate the Feature on a specified subsite
  9. Then reset Microsoft Internet Information Services (IIS) so that the changes can take effect.
  10. To see the various custom actions that you have added, navigate to the following locations from the home page of a Web site in the site collection:
  • Click Site Actions to see the new action on the Site Actions menu.
  • Click Site Settings on the Site Actions menu to see a new action in the Look and Feel section of the Site Settings page.
  • Navigate to a document library and open each menu on the toolbar to see a new action on each menu.
  • In a document library that contains items, click the down arrow for an item to see the new action on the edit control block menu.
  • On the edit control block menu for an item, click View Properties and Edit Properties to see new actions on the Display form and Edit form toolbars.

here you find some Default Actions: http://msdn.microsoft.com/en-us/library/bb802730.aspx

Elements.xml

<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
<!– 1. Document Library Toolbar New Menu Dropdown –>
<CustomAction Id=”UserInterfaceLightUp.DocLibNewToolbar”
RegistrationType=”List”
RegistrationId=”101″
GroupId=”NewMenu”
Rights=”ManagePermissions”
Location=”Microsoft.SharePoint.StandardMenu”
Sequence=”1000″
Title=”MY DOCLIB NEW MENU TOOLBAR BUTTON”>
<UrlAction Url=”/_layouts/LightupHello.aspx?NewMenu”/>
</CustomAction>

<!– 2. Document Library View Toolbar Main Link –>
<CustomAction Id=”UserInterfaceLightUp.DocViewToolbarStatic”
RegistrationType=”List”
RegistrationId=”101″
Rights=”ManagePermissions”
Location=”ViewToolbar”
Sequence=”1001″
Title=”MY STATIC VIEW TOOLBAR ITEM”>
<UrlAction Url=”/_layouts/CustomHello.aspx?ViewToolbar”/>
</CustomAction>

<!– 3. Document Library Toolbar View Toolbar Main Control –>
<CustomAction Id=”UserInterfaceLightUp.DocViewToolbarDynamic”
RegistrationType=”List”
RegistrationId=”101″
Rights=”ManagePermissions”
Location=”ViewToolbar”
Sequence=”1000″
ControlSrc=”~/_controltemplates/CustomHello.ascx“>
</CustomAction>

Read the rest of this entry »

Posted in ASP.NET, Deployment, MOSS, UserControls | Tagged: , , , , | 1 Comment »

Introduction in SharePoint Field Types

Posted by PANVEGA on March 28, 2007

DeeThis is the first post of some of theme I am going to write about this topic, and I will use it to introduce in the concept of the custom field types.

In MOSS, and for any list, we can create columns based on a great number of different field types, that let us to work with the information in many different ways. But, some times, we could need something more adapted.

They allow you to create your own subclasses of the existing SharePoint field types. You can control pretty much every aspect of the fields behavior. Things such as how the field is displayed/rendered in the SharePoints interface, how the data is formatted when it gets stored in the field, validation, and all kinds of other cool stuff.

To create a custom field type, you can extend a default Windows SharePoint Services field type by defining a custom field type and control for displaying the field, and then adding a field type definition to register the field type and its control.

Read the rest of this entry »

Posted in ASP.NET, Deployment, DotNet, MOSS, UserControls | Tagged: , , , , | Leave a Comment »

Developing Custom Field Types

Posted by PANVEGA on February 18, 2007

In this post i am going to introduce how to develope a custom field type in 6 steps with the Sharepoint People Picker. Search the name you want, push the button in order to resolve the user enitities in the code behind class. Finnaly return the parsed values to a simple multiline text box. You can also create a datagrid or just a table to format the values.

First of all we are going to create the visual user interface. As the custom field will be deployed as an feature assembly, it is a good idea to create a class library project in Visual Studio 2005 or Visual Studio 2008. Prepare also the folder structure that is required for a feature. Read the rest of this entry »

Posted in ASP.NET, Deployment, DotNet, JavaScript, UserControls, WebParts | Tagged: , , , , , , | Leave a Comment »