Solved

SharePoint Column Value on Page

Posted on 2010-11-15
7
539 Views
Last Modified: 2012-05-10
Is there a way to take a value from a given list within a site and have that value displayed on a page without haveing to display the column names or list.  I have a list that defines a project and that list has a title of the project in it.  I want to take that title and have it displayed on the top of the page.  I figure this is simple but not finding it.
0
Comment
Question by:JoMar
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:tstritof
ID: 34140040
Hi,

could you please explain your request with more detail? By what criteria should a project be chosen from project list in order to display the title? What data in a page can be used to query the project list?

Regards,
Tomislav
0
 
LVL 42

Expert Comment

by:zephyr_hex (Megan)
ID: 34140059
it's not so simple ;)

by "top of the page", do you mean the browser bar?  or a section of the actual page near the top?

if you mean a section of the page near the top, then you can do this using Sharepoint Designer.

bring up the page in Designer.  put Designer in split code/page view so you can see elements on the page and the code at the same time.  click on the field in the design/page view and it should hop to that section in the code.  that will show you how to reference the field in the top section of your page.

if you want it in the browser title bar, that's a whole 'nother ball of wax...
0
 
LVL 42

Expert Comment

by:zephyr_hex (Megan)
ID: 34140065
sorry... once again i forgot to flip to EE Comment mode.

here we go:
it's not so simple ;)

by "top of the page", do you mean the browser bar?  or a section of the actual page near the top?

if you mean a section of the page near the top, then you can do this using Sharepoint Designer.

bring up the page in Designer.  put Designer in split code/page view so you can see elements on the page and the code at the same time.  click on the field in the design/page view and it should hop to that section in the code.  that will show you how to reference the field in the top section of your page.

if you want it in the browser title bar, that's a whole 'nother ball of wax...
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:JoMar
ID: 34140304
I have a site that contains a list that contains a field ("Title") in it.  

I also have a home.aspx page that users go to when they first open the site.  What I want is to take the value from the above list and display it as a header on the home.aspx page.

I am not worried about quering the list as it should only have 1 value in it anyway.  Also, not worried about the browser title.
0
 
LVL 42

Expert Comment

by:zephyr_hex (Megan)
ID: 34140849
displaying that value in the "out of the box" title is going to take coding that is beyond my level of expertise.  i'm sure it can be done.  but not easily.

however, you can likely mimic or get close to the "out of the box" title using other tools.  for these methods, you would modify the code on your main page to add something that looks like the title bar, with the lookup value you want.

here are some methods you could use:
http://www.a2zdotnet.com/View.aspx?id=100

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

0
 
LVL 7

Accepted Solution

by:
tstritof earned 500 total points
ID: 34142218
Hi,

although I'm not sure I agree with your concept of having a single item WSS list to change the title of the home page I tried to work it out in a little example (just kidding about the concept, I guess you just gave a sandbox example :)).

The screenshots from the example are from my testing site so please disregard the various silly named lists and libraries.

In the first screenshot I displayed a standard (non-customized) WSS home page.
 Standard WSS home page.
The second screenshot shows the contents of a WSS list named "Projects".
 WSS list Projects.
The third screenshot shows the "unpolished" output of customized home page. Since I wasn't sure which location you wanted for your "project title" I embedded it in 2 locations.
 Customized WSS home page.
If this is what you had in mind - read on. If not, please read on anyway - I'll feel better :)

The "solution" has been developed on standard WSS 3.0 installation and is deployed through 2 main steps:
1) Creation and deployment of custom WSS user control named MyPageTitle.ascx.
2) Creation of custom home.aspx page (from default.aspx) that utilizes the new control.

Additionally you'll have to create a list named "Projects" and create at least one item with some title in the list. If you want to name your list differently you can do that but you'll have to modify the ascx accordingly.

If you're using a different version of WSS or MOSS you might run into some problems with deployment. Also MOSS might have some built-in functionality that solves your problem more elegantly but I'm not aware of it (I'm happy playing with WSS - can do less damage).

You'll find both files are attached to this post and here's a little how-to regarding deployment.

The MyPageTitle.ascx file contains:
- the code that queries the list named "Projects" in the current site
- the label that displays the value of "Title" field for the first item it retrieves from the list

To make the control available to WSS pages you'll have to:
- create the "CustomControls" folder in your CONTROLTEMPLATES folder (it's full path is usually "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\CONTROLTEMPLATES")
- copy the MyPageTitle.ascx file to newly created "CustomControls" folder

This deployment should ensure that you don't overwrite any standard WSS user controls (hence the new folder) and prevent any in-line scripting related security problems in WSS since controls deployed to CONTROLTEMPLATES should all be treated as safe by WSS.

The home.aspx can be uploaded to standard WSS 3.0 site document library and tested without any modifications to your WSS site or you can make small customizations to your existing pages (using Sharepoint Designer or other tools). The modifications could also be deployed to master page template but I don't recommend it since this is just a sandbox solution (not tested for stability or much else for that matter).

The first thing to do in the aspx page was to register the new web control. One line has been added to standard default.aspx page code to achieve this (note the path to the ascx):
<%@ Register TagPrefix="mst" TagName="MyPageTitle" src="~/_controltemplates/CustomControls/MyPageTitle.ascx" %>

Open in new window


Both places where title is changed are relying on this new ascx control to do the querying/displaying magic.

However, in order to display the title instead of the site title, the code had to be added to override default content for PlaceHolderSiteName content place holder (which is normally defined in the default.master). That has been achieved by 3 new lines (immediately following the line where web control was registered):
 
<asp:Content ContentPlaceHolderId="PlaceHolderSiteName" runat="server">
	<mst:MyPageTitle ID="MyPageTitle_id1" runat="server"/>
</asp:Content>

Open in new window


And finally a single line of code has been added to target the PlaceHolderPageTitleInTitleArea content place holder (I didn't delete any standard content targeting the same place holder, but you may do that yourself). This is the line (I removed the indent here):
 
<mst:MyPageTitle ID="MyPageTitle_id2" runat="server"/>

Open in new window


And that is it - not much code but not much "bang" either :) The files are here:
 MyPageTitle.ascx
 home.aspx

I was thinking to give you an example of how to solve this by "dirty client side solution" (hidden list web part querying Projects + javascript hidden away in CEWP webpart) without any modification to aspx code but the code and entire solution would be to unstable to actually implement in production environment.

Hope you can make some use of this :).

Regards,
Tomislav
0
 
LVL 7

Expert Comment

by:tstritof
ID: 34142231
Sorry for the huge code snippet windows, I have no idea why that happened (looks like too long lines of code are the culprits).

Regards,
Tomislav
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaScript waiting 14 80
Can I use the same managed account for my new sharepoint farm 3 23
HTML File in SharePoint 2013 Library 4 56
Sharepoint 2010 2 11
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Microsoft has released remote PowerShell capabilities to all commercial Office 365 customers. So you can be controlled via PowerShell and not from the Office 365 admin center Download Windows PowerShell Module for Lync Online http://www.micros…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question