It seems that links in Sharepoint 2007 lists still open in the same window. There is no build in option to change this as far as I know, so what I did was create a new field type.
I've based this on an article from Patrick Tisseghem that can be found here.
I could not get the sample to work. In the end I found that I had an inherits statement in the control's ascx that did not need to be in there.
The steps to create the custom field are:
- Create a class for the value of the field
- Create a class custom field itself
- Create a class for the control that is used for rendering (it uses a control template for the actual rendering)
- Create an ascx file containing the rendering template
- Create a field type definition file
- Deploy, register as safe control and recycle the app pool
Here is the code:
1. LinkFieldValues.cs
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace MyCompany.MOSS.Web.Link
{
public class LinkFieldValue: SPFieldMultiColumnValue
{
private const int numberOfFields = 3;
public LinkFieldValue()
: base(numberOfFields)
{ }
public LinkFieldValue(string value)
: base(value)
{ }
public string Hyperlink
{
get { return this[0]; }
set { this[0] = value; }
}
public string Description
{
get { return this[1]; }
set { this[1] = value; }
}
public string Target
{
get { return this[2]; }
set { this[2] = value; }
}
}
}
2. LinkField.cs
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace MyCompany.MOSS.Web.Link
{
class LinkField: SPFieldMultiColumn
{
public LinkField(SPFieldCollection fields, string fieldName):base(fields, fieldName)
{
}
public LinkField(SPFieldCollection fields, string typeName, string displayName)
: base(fields, typeName, displayName)
{
}
public override Microsoft.SharePoint.WebControls.BaseFieldControl FieldRenderingControl
{
get
{
BaseFieldControl fldControl = new LinkFieldControl();
fldControl.FieldName = InternalName;
return fldControl;
}
}
public override object GetFieldValue(string value)
{
if (string.IsNullOrEmpty(value))
{
return null;
}
return new LinkFieldValue(value);
}
}
}
3. LinkFieldControl.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
namespace MyCompany.MOSS.Web.Link
{
class LinkFieldControl : BaseFieldControl
{
protected TextBox hyperlinkTextBox;
protected TextBox descriptionTextBox;
protected DropDownList targetDropDownList;
protected override string DefaultTemplateName
{
get { return "LinkFieldRendering"; }
}
public override object Value
{
get
{
EnsureChildControls();
LinkFieldValue fieldValue = new LinkFieldValue();
fieldValue.Description = descriptionTextBox.Text.Trim();
fieldValue.Hyperlink = hyperlinkTextBox.Text.Trim();
fieldValue.Target = targetDropDownList.Text.Trim();
return fieldValue;
}
set
{
EnsureChildControls();
LinkFieldValue fieldValue = (LinkFieldValue)value;
descriptionTextBox.Text = fieldValue.Description;
hyperlinkTextBox.Text = fieldValue.Hyperlink;
targetDropDownList.SelectedValue = fieldValue.Target;
}
}
public override void Focus()
{
EnsureChildControls();
hyperlinkTextBox.Focus();
}
protected override void CreateChildControls()
{
if (Field == null)
return;
base.CreateChildControls();
if (ControlMode == SPControlMode.Display)
return;
hyperlinkTextBox = (TextBox)TemplateContainer.FindControl("hyperlinkTextBox");
if (hyperlinkTextBox == null)
throw new ArgumentException("Corrupted LinkFieldRendering template - missing hyperlinkTextBox.");
hyperlinkTextBox.TabIndex = TabIndex;
hyperlinkTextBox.CssClass = CssClass;
hyperlinkTextBox.ToolTip = Field.Title + " Link";
descriptionTextBox = (TextBox)TemplateContainer.FindControl("descriptionTextBox");
if (descriptionTextBox == null)
throw new ArgumentException("Corrupted LinkFieldRendering template - missing descriptionTextBox.");
descriptionTextBox.TabIndex = TabIndex;
descriptionTextBox.CssClass = CssClass;
descriptionTextBox.ToolTip = Field.Title + " description";
targetDropDownList = (DropDownList)TemplateContainer.FindControl("targetDropDownList");
if (targetDropDownList == null)
throw new ArgumentException("Corrupted LinkFieldRendering template - missing targetDropDownList.");
targetDropDownList.TabIndex = TabIndex;
targetDropDownList.CssClass = CssClass;
targetDropDownList.ToolTip = Field.Title + " target";
if (ControlMode == SPControlMode.New)
{
hyperlinkTextBox.Text = Field.GetCustomProperty("DefaultHyperlink").ToString();
descriptionTextBox.Text = Field.GetCustomProperty("DefaultDescription").ToString();
targetDropDownList.SelectedValue = Field.GetCustomProperty("DefaultTarget").ToString();
}
}
}
}
4. LinkControl.ascx
<%@Control Language="C#" Debug="true" Inherits="MyCompany.MOSS.Web.Link.LinkFieldControl"%>
<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
<SharePoint:RenderingTemplate ID="LinkFieldRendering" runat="server">
<Template>
<asp:TextBox runat="server" id="hyperlinkTextBox" MaxLength="400" Size="40"/>
<asp:TextBox runat="server" id="descriptionTextBox" MaxLength="100" Size="40"/>
<asp:DropDownList runat="server" id="targetDropDownList">
<asp:ListItem Value="_Blank" Text="Nieuw Venster"/>
<asp:ListItem Value="_Self" Text="Dit Venster"/>
</asp:DropDownList>
</Template>
</SharePoint:RenderingTemplate>
5. fldtypes_LinkControl.xml
<?xml version="1.0" encoding="utf-8"?>
<FieldTypes>
<FieldType>
<Field Name="TypeName">MyLink</Field>
<Field Name="ParentType">MultiColumn</Field>
<Field Name="TypeDisplayName">My Link</Field>
<Field Name="TypeShortDescription">My Link (Link, Description, Target)</Field>
<Field Name="UserCreatable">TRUE</Field>
<Field Name="ShowOnListAuthoringPages">TRUE</Field>
<Field Name="ShowOnDocumentLibraryAuthoringPages">TRUE</Field>
<Field Name="ShowOnSurveyAuthoringPages">TRUE</Field>
<Field Name="ShowOnColumnTemplateAuthoringPages">TRUE</Field>
<Field Name="FieldTypeClass">MyCompany.MOSS.Web.Link.LinkField,MyCompany.MOSS.Web.Link, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null</Field>
<PropertySchema>
<Fields>
<Field Name="DefaultHyperlink" DisplayName="Default Link:" MaxLength="400" DisplaySize="40" Type="Text">
<Default>http://www.nu.nl</Default>
</Field>
<Field Name="DefaultDescription" DisplayName="Default Description:" MaxLength="100" DisplaySize="40" Type="Text">
<Default>Nieuws</Default>
</Field>
<Field Name="DefaultTarget" DisplayName="Default Target:" MaxLength="20" DisplaySize="20" Type="Text">
<Default>Nieuw Venster</Default>
</Field>
</Fields>
</PropertySchema>
<RenderPattern Name="DisplayPattern">
<Switch>
</Expr>
<Case Value="">
</Case>
<Default>
<HTML><![CDATA[<A HREF="]]></HTML>
<Column SubColumnNumber="0" HTMLEncode="TRUE"/>
<HTML><![CDATA[" target="]]></HTML>
<Column SubColumnNumber="2" HTMLEncode="TRUE"/>
<HTML><![CDATA[">]]></HTML>
<Column SubColumnNumber="1" HTMLEncode="TRUE"/>
<HTML><![CDATA[</a>]]></HTML>
</Default>
</Switch>
</RenderPattern>
</FieldType>
</FieldTypes>
6. Deploy
- Place the dll in the GAC
- Copy the xml file to c:\program files\common files\microsoft shared\web server extensions\12\template\xml
- copy the ascx file to c:\program files\common files\microsoft shared\web server extensions\12\template\controltemplates
- Add this line to the safecontrols section in the web.config file:
<SafeControl Assembly="MyCompany.MOSS.Web.Link, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace="MyCompany.MOSS.Web.Link" TypeName="*" Safe="True" />
Ben gelukkig weer eens bezig met een asp.net web project. Liep toevallig tegen het volgende tooltje van Microsoft aan. Had al wel eens soortgelijke gezien, maar deze lijkt me toch vrij cool.
Het geeft op een gemakkelijke manier allerlei info over een webpagina.
Hier is de download: http://www.microsoft.com/downloads/details.aspx?FamilyID=e59c3964-672d-4511-bb3e-2d5e1db91038&DisplayLang=en
Dit is wat ms erover zegt:
Overview
The Internet Explorer Developer Toolbar provides several features for exploring and understanding Web pages. These features enable you to:
-- Explore and modify the document object model (DOM) of a Web page.
-- Locate and select specific elements on a Web page through a variety of techniques.
-- Selectively disable Internet Explorer settings.
-- View HTML object class names, ID's, and details such as link paths, tab index values, and access keys.
-- Outline tables, table cells, images, or selected tags.
-- Validate HTML, CSS, WAI, and RSS Web feed links.
-- Display image dimensions, file sizes, path information, and alternate (ALT) text.
-- Immediately resize the browser window to a new resolution.
-- Selectively clear the browser cache and saved cookies. Choose from all objects or those associated with a given domain.
-- Choose direct links to W3C specification references, the Internet Explorer team weblog (blog), and other resources.
-- Display a fully featured design ruler to help accurately align and measure objects on your pages.
The Developer Toolbar can be pinned to the Internet Explorer browser window or floated separately.
This Beta 2 version of the toolbar contains functionality and stability enhancements over previous versions and includes the following improvements.
-- You can now selectively enable and disable CSS parsing.
-- The Misc menu contains a color picker.
-- Several link reports are available.
-- When you select an element in the DOM element tree list, the selected element scrolls into view if it is not already visible in the browser window.
When we set up the portal for my current client we decided that all departments were to get a wss site to store documents etc. These site were also accessible to colleagues from other departments. If you set the rights correctly there is nothing really wrong with this set-up. However, the problem we've experienced is that employees from other departments get to see options in which they are not interested and probably will not have access to anyway.
Then it occurred to me that using area's to store information about a department for employees outside the department is a good solution. Every department now gets an area besiedes their existing wss site. In the area they define what other users can see. The wss site is used for internal collaboration only. If they have documents that are meant to see by the organisation they can publish it to the portal from their wss site or place it in the area itself. The only thing I have to figure out is how I can set the rights so that some documents in a document library can be accessed everyone and other's can't. I've got a feeling that this will not possible and that I have to create a seperate library for this. Not ideal but it will work. Suggestions are welcome.
Today I decided to create a new area in a Sharepoint portal. I then decided that I wanted to customize the resulting page.
What I failed to notice is that the area was created from a default template. After making some changes to this area I noticed that other area's now looked like my new area.
We have choosen to let new area's inherit from a template so that we do not have to modify all templates if we make a change. The only thing you have to remember then is to break the inheritance before customizing a particular area.
This post is to warn about the dangers of restoring a SharePoint portal.
This week somebody accidentally deleted an area on a portal. Fotunately we had a sql back-up of our Sharepoint Database. However when trying to create a new portal to point to these databases something went wrong in the configuration database which resulted in our production portal not being available.
Research showed that the content was still present. Apparantly the restore had resulted in a change in the configuration database so that all the sites pointed to the restore portal instead of our production portal.
After an update query to reset the DatabaseID's everything was fine again. This was tricky though since direct manipulation of the database is strongly dissuaded.
The good thing about this event is that now everybody is convinced we need a better back-up & restore procedure which was something I've been asking for a long time.
We will start with using the sharepoint back-up tool and later may-be buy a third party tool that is capable of restoring individual items.
Anybody got any experience to share about best practices for backing-up sharepoint portals and sites?
Mike Fitzmaurice is the technical product manager for Microsoft SharePoint products and technologies.
He has started blogging: http://blogs.msdn.com/mikefitz/
I've seen Mike at a presentation in Cannes (yes, Cannes in France) last year. I find him an excellent speaker with a lot of humor, so I expect great things coming from him.
A while ago I was looking in Sharepoint to find the option where to view the usage details of a portal area. In a WSS site it can be found under Site Settings/Site administration/View Site Usage data. I'm fairly sure now that it is not available through the admin pages of a Sharepoint Portal.
However, if you remove the last part of the url of a portal site and replace it with _layouts/1033/usagedetails.aspx you will find the statistics. (ie for www.myportal.com/default.aspx you can view the statistics at www.myportal.com/_layouts/1033/usagedetails.aspx ). Please note that 1033 may vary depending on the language version of your sharepoint installation.
This not only works for statistics, but for every admin page of a wss site. This is actually obvious if you realize that Sharepoint Portal Server is built on top off WSS.
To keep up with all the end of year top lists of things, I thought to share the things I dislike the most about SharePoint.
Bear in mind though that I do like SharePoint a lot, so I will probably also be posting a list of things I like most as well in the near future. Remember this is my personal list, so if you've got solutions to my issues or if've you're more annoyed about other things in sps please let me know.
- Visibility of options you can't use. A lot of users I know complain about the fact that they can often go very far in the Sharepoint system only to be dissapointed when they find out they haven't got enough permissions. According to Microsoft, this is by design.
- Very loosely coupled listings. In Sharepoint you can have listings that refer to a for instance. Moving, renaming or deleting the document result in a broken link.
- Customizing the look and feel of Sharepoint can be a pain in the ...If you go beyond the stylesheet changes (and there are a lot of styles!) you find yourself struggling with CAML, javascript and Frontpage (for crying out loud!). Not an easy job in my opinion. And if you want to make a general change to already existing pages and sites you can also run into problems.
- Unclear navigation. This is another thing I see users struggling with, The quick menu navigation is context sensitive so it changes depending on where you are. It also gives you no option to go directly to a node that is on the same branch (what is the word I'm looking for here?) This is very confusing for a lot of users. And it is not easily customizable either.
- A lot of the cool stuff requires Office 2003. The use of office 2003 gives users far greater experience then say office XP. However, this is not enough to convince clients to upgrade to Office 2003, so I find myself explaining a lot of times that a certain option is only available in Office 2003 (again the option is often visible in the portal regardsless of the ce version a client has, see issue 1)
- The page viewer webpart doesn't work well in folder view page viewer webpart allows you to show a file, folder or another webpage in a webpart window on the portal page. However, it has no option to set the deafult view when in folder view mode. So my users have to change the view from pictograms to details each time they visit the page (the pictogram view shows only part if the file names are long).
- Setting up Sharepoint as an extranet in a hosted environment. About half a year ago we started deploying some sites at a hosting party. The environment is quite complex with load balancers, proxies, apache webservers, firewalls etc. We are still not a stage where we feel we can comfortably use Sharepoint in this environment.
- Choosing new document from the document library toolbar. There is no option here to specify the type of file you wish to create.
- Lack of wizards. ln several places in Sharepoint the user has to provide details which he should have copied to the clipboard first (ie a url to a picture). it would have been much better to be able to browse for this information.
- Settings on doc library can not be set at subfolder level. Because of this users are forced to put related documents in separate libraries if they want to have different access levels.
I feel I have just started and have many more such as missing workflow, limited document management and more. I hope some of the issues mentioned here help you in your projects. Some of these issues I feel are also changes to create some custom solutions (anybody interested?).
My current client has decided to convert their component framework from VB.NET to C#. The main reason being that they want to have other parties to build upon their framework and most of the parties they work with code in C#.
Now I don't want to start a new session again about what language is better, cause I haven't made up my mind yet. What I do know however that event though we use a converter tool, I still spend practically all day today getting the damn thing to compile.
According to the converter tool it was able to convert 97.5%. But I must have gone through hundreds of task list entries today. What I do like about C# already is that is shows how much VB does behind the scenes. I suddenly noticed unused variables, unreachable code, variables that were never assigned and more.
And for some reason we are not allowed to use the Microsoft.VisualBasic dll any more, which resulted in rewriting a lot of collections, trims, rights, redim statement etc.
So that's one down, 25 to follow woohoo.