views:

1044

answers:

3

A page within our MOSS publishing website has a property which is a lookup field.

I only want the selected text to be displayed when you view the page not in edit mode, but when I use the Microsoft.SharePoint.WebControls.LookupField it generates a hyperlink to the SharePoint list item (obviously bad).

Is there a way around this, short of creating my own lookup field control?

A: 

I ran into this problem also. The only way I found was to create my own control.

Nathan DeWitt
A: 

To get rid of the link;

You can create a displaytemplate.ascx as below

<%@ Control Language="C#" Debug="true" %> <%@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="LookupDisplayTemplate" runat="server"> &blockquote&Template> &blockquote&SharePoint:FieldValue ID="FieldValue1" runat="server" ControlMode="Display"/> &blockquote&/Template> &blockquote&/SharePoint:RenderingTemplate>

Then. use it as below.

&blockquote&SharePoint:LookupField id="LookupField1" FieldName="" runat="server" DisplayTemplateName="LookupDisplayTemplate"/>

Then it works.

Hope it helps :)

Sebnem

A: 

You can use a jQuery hack

Using JQuery to remove Linked List Items hyperlinks.

<script type="text/javascript" src="/jquery-1.3.1.js"></script>

<script type="text/javascript">
$(document).ready(function() {
   $('a[href*="RootFolder=*"]').each(
      function(index) {
         var link = $(this);
         $(this).after("<span>" + link.text() + "</span>");
         $(this).remove();
      });
});
</script>
Ryan