Tangible Thoughts

SharePoint, MOSS? and all the other questions

  Home  |   Contact  |   Syndication    |   Login
  858 Posts | 6 Stories | 482 Comments | 2088 Trackbacks

News

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Linky Things

SharePoint Bloggers

SharePoint Related

What I am playing

What I am Reading

A couple of my colleauges who as far as I know have all their life worked with ASP (mind you not ASP.NET, just the now aged ASP) were trying to dip their feet into SharePoint. One of them developing a paticular WSS site kept insisting on the need for an asp include file to create a bit of jazzy navigation.

Now as you know SharePoint does not allow include files. So I proposed for all the links to be on a WSS list and then render the navigation by means of DVWP. Yes this can be done, but to create some Jazzy UI effects its a bit tedious. For quite some time I was playing around with the DVWP trying to recreate the Jazzy Naviagation and tollerating all the whining going on around me.

Then it suddenly dawned on me. You could actually sort of emulate ASP include files using the DVWP, at least for the current requirement. You see in this paticular requirement the include file only contains HTML and JavaScript. The purpose of the include file was to have a single location to edit if any of the navigation links change and a single location to edit to change the presentation aspects of the navigation. And if you are thinking how about replacing the default header with an alternate header, that wouldnt do, because this is a left navigation that would be used in addition to the default header. And if you are thinking just write a WebPart, that would take too long.

The fastest way of emulating the above is to dump the HTML that would make up the Navigation into a CDATA section of an XML file. Host the XML file on the WSS Site. Setup a DVWP to use the XML file a DataSource. Render the CDATA element with enable content escaping = Yes, and voila! you are done.

posted on Wednesday, June 29, 2005 6:49 AM

Feedback

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 6/30/2005 7:31 AM Vijay shankar ganesh K
Thats a good one

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 7/30/2005 12:41 AM 画册设计
very good!!

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 9/15/2005 1:45 PM Tony
An example would be good!

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 9/16/2005 3:22 PM Larry
Even simpler is to place the file to be included in the same virtual directory as the default.aspx file for the area. Use that file name as the xml source in the XML Web Part. The page renders just fine, as though it was an old-style <!-- #INCLUDE... file.

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 7/12/2006 8:45 AM François Karman
I found a simpler solution to resolve this problem, in one line :
<!--webbot bot="Include" U-Include="/mypage.aspx" TAG="BODY" -->

Actually, Frontpage don't allow you to use aspx or asp files for this "bot" but that works perfectly !

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 7/21/2006 1:19 PM Jeff Rush
SharePoint will take include files like so:

<!--#include virtual="/_LAYOUTS/1033/CHS_Common/footer.html"-->

CHS_Common is just a dir I store some coomon files btw

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 10/30/2006 7:58 AM Soumendra
I tried the same approach <!--#include virtual="/...... " but it gives access denied error.

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 4/17/2008 6:29 AM Ken
I tried the same on WSS 3.0 Masterpage <!--#include virtual="/...... " but got error which said the Include was not allowed on the page.

Funny that running an ASP2.Net application on a non-SharePoint site will allow Includes.

Anyway, grumbiing won't change things but an Example to go with the above suggestion to use DVWP would be Good and Helpful to newbee SharePoint Developers like me.
I'm an old ASP Developer who can't understand why Microsoft would eliminate useful and functional #Includes from SharePoint. Seems another dumb move to me. I guess they had their reasons. There I go againg gumbling...

However, I'm always open to something better but what replaces it? If any info on this then please give an example.

Thanks

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 4/21/2010 10:39 PM Nick
Awesome hack - just what I've been looking for.
For those that are struggling, create an XML file with the information you want as an includes, wrapped in a CDATA XML element. Save this file to a document store on your Sharepoint. Then, use the XML Web Part to call this XML file on each page you want it shown.

Abracadabra, your html/javascript is rendered by your browser!

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 5/18/2010 10:19 PM Naresh
The webbot solution works fine for me,,,I am able to see the navigation in the SharePoint Designer design mode but not in the SharePoint page. Is there a setting that I need to do?? Please let me know...
Thanks!!

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 7/16/2010 11:31 PM snasri
Thanks! That helped a whole lot. Now I just have to figure out how to include files with asp tags and webparts.

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 7/23/2010 4:40 AM Phil
Alternately:
1) You can host your "include HTML" in an ASCX control under the ControlTemplates folder (don't even need any code behind) and then reference the ascx in your master page or page layout.
2) You can use a Content Editor Web Part - rather than putting the source HTML in the editor, you can simply reference another file.
, you could just use a content editor web part! Rather than specifying the code as part of the web part property.


# re: Include files arent allowed in SharePoint but then there is the DVWP right? 12/10/2010 3:19 AM Danielle
Phil, your #2 solution is the best. Works well and was so simple. Why didn't I think of that? Thanks!

# re: Include files arent allowed in SharePoint but then there is the DVWP right? 2/22/2011 12:42 PM Daniel
Where do I set enable content escaping = Yes?

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: