Simple Trick for making an existing web part async
Friday, February 05, 2010 3:10 PM

This is one of my favorite stupid SharePoint tricks.

If you have a situation where there is a web part (or any web page component) that is slow, and it is slowing the page render time for your page this is a handy trick.

Here is the summary:

  1. Create another web part page and add the slow loading web part.
  2. Look at the source code for the render page and get the control id of the div tag for the web part (the skewer click in the IE8 dev toolbar or something similar is an easy way to do this).
  3. Back on the page where you originally wanted the web part, add a content editor web part
  4. Put the following script in the source of the web part:
var ctId="ctl00_"; //Replace this with your control ID from step 2
var sourceURL="http://YourServer/somesite/PageThatHasTheSlowWebPart.aspx";
var outputId="MakeshiftAsyncWebPart";

_spBodyOnLoadFunctionNames.push("renderASlowWebPartAsynchronously"); 

function renderASlowWebPartAsynchronously()
{
      loader(sourceURL);
}

function renderOutput(output)
{
document.getElementById(outputId).innerHTML=output;
      
}

function getElementByClassname(className)
{
      var allItems = document.all;
      for (var i=0; i < allItems.length; i++) 
      {
            if (allItems[i].className == className) 
            {
                  return allItems[i];
            }
      }
      return null;
}

function getElementByClassnameFromString(className,str)
{
      var myTempDiv=document.createElement("div");
      myTempDiv.innerHTML=str;
      
      var allItems = myTempDiv.all;
      for (var i=0; i < allItems.length; i++) 
      {
            if (allItems[i].className == className) 
            {
                  return allItems[i];
            }
      }
      return null;
}

function getElementByIDFromString(myID,str)
{
      var myTempDiv=document.createElement("div");
      myTempDiv.innerHTML=str;
      
      var allItems = myTempDiv.all;
      for (var i=0; i < allItems.length; i++) 
      {
            if (allItems[i].id == myID) 
            {
                  return allItems[i];
            }
      }
      
      return null;
}

function loader(url) {
  
  if (window.XMLHttpRequest) {
    request = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    request = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (request != undefined) 
  {
    request.onreadystatechange = function() {asyncHandler(url);};
    request.open("GET", url, true);
    request.send("");
  }
}  

function asyncHandler(url) 
{
  if (request.readyState == 4) 
  { 
    if (request.status == 200) 
    {
      var output=getElementByIDFromString(ctId,request.responseText).innerHTML;
      if (output==null)
      {
            /* 
            //Optional:  
            output="No results";
            renderOutput(output);
            */
      }
      else
            renderOutput(output);
    } 
    else 
    {
      //Optional
      //document.getElementById('dOutput').innerHTML=" Error: "+ request.status + "\n" +request.statusText;
    }
  }
}

<div id=”MakeshiftAsyncWebPart”></div>

 

You can even reference an Animated GIF in SharePoint 2007 for AJAX progress indicators so that users know the web part is loading.

Keep in mind that users won’t get the security prompt for cross site scripting if the two pages are on the same server.

Of course: This code is provided as an example. Use at your own risk. No warranties.

by wkriebel | with no comments
Animated GIFs in SharePoint 2007 for AJAX progress indicators
Tuesday, January 26, 2010 2:22 PM

Here are possible AJAX animation alternatives in http://<myMOSSServer>/<anysiteurl>/_layouts/images/

  • Ewr133.gif or GEARS_AN.gif (same)
    clip_image001
  • Kpiprogressbar.gif
    clip_image002
  • Ewr120.gif
    clip_image003
  • Crperspc.gif
    clip_image004

These gifs are on all MOSS servers and can be used if you need a quick progress indicator image.

by wkriebel | 2 comment(s)
Filed under:
SharePoint Wiki Page Incoming Links Web Part
Wednesday, October 14, 2009 1:36 PM

Ever want the “Incoming Links” page to show up on the wiki page rather than be a separate page?  Well, here is a handy web part you can add to a wiki page.

This provided without warranty, just link to this article and tell folks how you used it.

It uses some clever JavaScript to get the content from that page and asynchronously render it in a web part.

  1. Upload the Incoming Links.dwp file to your Web Part Gallery
  2. Edit the wiki page in question (not the wiki content, the whole page)
  3. Add the Incoming Links web part to the web part zone at the bottom of the page.

This will either prevent you from the hassle of also having to support wikimedia in your environment (which is really great if you can) or buy you time until you can deploy SharePoint 2010.

by wkriebel | 1 comment(s)
Filed under:
Setting Project Priorities from TFS Priorities
Wednesday, September 16, 2009 11:13 AM

Here is a handy macro that allows me to set the task priorities in Microsoft Project 2007 based on tasks that I have imported/synchronized to Visual Studio Team System. 

The reason I do this is because this allows me to have dependencies between TFS work items, determine which ones need to happen first, level my resources, and calculate completion dates for the work items.

 

Attribute VB_Name = "Module2"

Sub SetPriorityFromTFS()

Attribute SetPriorityFromTFS.VB_Description = ""

‘Description

    LevelingOptions Automatic:=False

    For Each T In ActiveProject.Tasks

        Select Case T.Text19

            Case 1

                T.Priority = "900"

            Case 2

                T.Priority = "700"

            Case 3

                T.Priority = "500"

            Case 4

                T.Priority = "300"

            Case 5

                T.Priority = "100"

        End Select

    Next T

    LevelingOptions Automatic:=True

    LevelNow

End Sub

DHS Threat Level SharePoint Web Part
Friday, August 28, 2009 3:03 PM

I recently created a XML Web part that uses XSL and the DHS Threat Level web service to render the current threat level in a way that looks exactly like the DHS Threat Advisory image:

clip_image002

Here it is for free to download with no warranty: DHS Thread Advisory.dwp

There is also an image: http://www.dhs.gov/threat_level/current-sm.gif

For fun, link to this post if you use the web part. 

by wkriebel | with no comments
Filed under:
How To Display the InfoPath Form Version on the Form
Wednesday, April 29, 2009 3:32 PM

Very handy for testing and help desk calls:

Tip: insert form version with the expression:
substring-before( substring-after( /processing-instruction()[local-name(.) = "mso-infoPathSolution"], 'solutionVersion="'), '"')

Source:  http://www.nivot.org/2008/09/30/WhyVSTO30VisualStudio2008SharePointWindowsWorkflowAndInfoPathMightGiveYouAHernia.aspx

by wkriebel | 1 comment(s)
Filed under:
Collect Data by Email
Tuesday, April 21, 2009 11:37 AM

Scenario: “Please respond to this email indicating your t-shirt size and which session you can attend… or whatever”   send to: 40 people.

Read this: http://office.microsoft.com/en-us/access/HA100154271033.aspx

by wkriebel | with no comments
How to Fix PWA Reminders web part in MOSS
Wednesday, April 01, 2009 10:46 AM

Add and hide this web part on the page where the reminders web part is located.

Often folks will want to export the Reminders web part from Project Web Access (PWA) 2007 and have it shown on a related SharePoint (MOSS) page.  You can export the web part, you can add it to a SharePoint page, you can set the PWA URL to your PWA URL and it will work. 

It will throw a javascript error.

The error presents itself as a document.stylesheets[0] etc. etc. javascript error and prevents all javascripts from running (such as menu flyouts).

The attached web part is simply a function redefinition that doesn’t require a feature deployment that fixes the reminders web part on that and only that page.

by wkriebel | with no comments
Filed under: ,
External Collaboration Toolkit for SharePoint (ECTS) Installation Notes
Thursday, January 29, 2009 5:40 PM

These notes are in addition to http://technet.microsoft.com/en-us/library/cc296362.aspx

These are the notes I generated that I used in overlay with the installation instructions. 

  1. Make sure Cert Server is installed and available
  2. Configure a certificate for ADAM
  3. Run ADAM setup from internet
    · Add/Remove only works if you have the OS disk
  4. Create DNS entries
    · For example: collab and collab.external
  5. Create Collab web app
  6. Reset IIS
  7. Create email address (e.g. SharePoint@yourdomain.com)
  8. Extend to an SSL external (e.g. collab.external)
  9. Create a site collection on the web application
  10. Run ADAM script that comes with kit
  11. Change the ADAM Service account
  12. Run database script
  13. Run SPScript
    Note: ADAM ports are typically 389, 636 or 50000, 50001
  14. Request IIS Cert
by wkriebel | with no comments
Filed under: ,
How I made my laptop faster
Thursday, January 29, 2009 12:18 PM

For some reason my laptop got really sluggish a while back.  Normally I wouldn’t blog about this type of thing, but it was so impactful I thought I would share.  I’ve already done and always do the typical stuff: defrag, clean registry, uninstall add-ons, maintain free disk space, etc.   This one, however, was the culprit.

Check this out if you are experiencing the same:   kb822158 Virus scanning recommendations for computers that are running Windows Server 2003, Windows 2000, Windows XP, or Windows Vista

Excerpt: “This article also contains information to help you minimize the effect of antivirus software on system and network performance.

by wkriebel | with no comments
More Posts Next page »