views:

549

answers:

1

I'm creating a SharePoint publishing master page and would very much like to be able to take properties from SharePoint field controls such as

<SharePointWebControls:UrlField FieldName="FAQ-Video" runat="server" />

and reuse them in object tags and jQuery elements.

Does anyone know how to do this?

+1  A: 

I'm not exactly sure how what you are doing isn't working... The UrlField control should output the URL title and wrap it in an <a> tag. You can then use jQuery to pull it apart and do what you like. If it doesn't have an ID that you can use (although you should be able to set that), just wrap the URL field in a <div> with the ID you want.

Edit after comment:

You need to be focussing on the page layout not the master page. Skip to the last paragraph if you already know the following...

To display the values of fields you must have a list item. In the case of a publishing site, these items exist in a Pages list. You may have browsed to this list (site/Pages/Forms/AllItems.aspx) and seen that it is just a standard SharePoint list allowing you to choose View Properties on any item and see the values of all the fields.

How this works from an end-user perspective is that all of these list items have an associated page layout (this is actually a field in the Pages list). The page layout contains controls such as UrlField to display and edit all of the fields for a page. So a page associated with a page layout and rendered in the browser is just another way of going to the Pages list and choosing View Properties on a list item.

When it comes to master pages - they don't know what to do with field controls. They simply provide the chrome while the page layout provides something more akin to a page template containing fields. There is no relationship between a list item and a master page. The relationship exists between a list item and a page layout. Whatever you'd like to do with the UrlField needs to be done in the page layout.

Alex Angas
You misunderstand, I need to do this in the master page, not the rendered page in the browser. In the case of lightbox I need to take the picture url and write it into the a tag surounding the image.i.e. <a href="[urlvalue]"><img/></a> etc.
toomanyairmiles
Perhaps I don't understand then. I've created a site master, a content type and a sub-master for that content type. This is where I'm placing the UrlField mentioned above. I would like to add an object tag to this page which renders different video files. Users would need to add a name and url for this video when creating the page in the browser the page-layout/submaster would then place the name and url in the correct place. Since I don't appear to be able to create a new data type and associated control which adds it to the page how should I go about this.
toomanyairmiles
You need to add the field to the page layout. Fields don't work when added to master pages. This should help you out a lot: http://office.microsoft.com/en-us/sharepointdesigner/HA101741281033.aspx
Alex Angas
I give in. I know fields don't work when added to master pages, and I've reviewed that diagram a number of times. I am putting the piece of code above in the page in which it's supposed to go. I simply want to break it's properties out and make different uses of them. I resorted to jQuery to solve the problem.
toomanyairmiles
For reference I'm using a page layout according to the diagram you supply - the people who trained me refer to them as sub masters.
toomanyairmiles
Sorry I couldn't help more, it's tricky over this medium. I'm glad you were able to work it out with jQuery!
Alex Angas