?
Solved

SharePoint Column Value on Page

Posted on 2010-11-15
7
Medium Priority
?
544 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 44

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 44

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
Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

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 44

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 2000 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
I have put this article together as i needed to get all the information that might be available already into one general document that could be referenced once without searching the Internet for the different pieces. I have had a few issues where…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

777 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