How can I work with SPUrl in my code-behind file for master pages and page layouts?
I don't see any access to this in the SharePoint namespaces.
|
How can I work with SPUrl in my code-behind file for master pages and page layouts? I don't see any access to this in the SharePoint namespaces. |
||||
|
|
|
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.webcontrols.spurlexpressionbuilder.aspx ... in your code behind, why not use SPContext to get the url path?
|
|||||||
|
|
Check out the SPUrlExpressionBuilder class |
|||
|
|
|
If I understand the question right, you should be able to work with the SPUrl expression builder by instantiating it in code, obtaining the expression result, then doing whatever you need to do. Alternatively if you're trying to work with an existing instance, you should be able to get it in the code-behind by ID, though you'd need to pay attention to when in the page lifecycle the actual expression building happens. Remember also that expression builders are typically only a wrapper anyway (generally around some logic which is more "central" but that you want to make use of in declarative markup), so you could get what you need by using a more direct route with the API e.g. per mike11steven's reply. If you need an example of a custom expression builder, my SharePoint Config Store project has one. |
|||
|
|