SharePoint 2007 Auto Page Refresh on Workflow Completion (SOLVED)

Posted in javascript, SharePoint, web development, xhtml with tags , , , , on December 9, 2011 by drew

Well, solved with some JavaScript that is.

This won’t be the ideal situation for everyone, but works for my immediate need and may well work for yours.  Use with caution!

The Problem:

Often in the SharePoint world we use a Workflow designed and deployed with SharePoint Designer to update a list field value.  Usually this is down when we want to include information from another list or something similar.

In my scenario, I was tasked with creating a simple Email Register that displayed a link with embedded subject and CC.  The subject needed an auto number included. The MSDN forums had the SharePoint auto number solution.

Once this was implemented I was on my way! Well, almost. Nasty SharePoint didn’t show the generated email link until AFTER the user refreshed the page (F5).

The Solution:

jQuery! (Really, where you expecting something else?)

Using the code below, I’ve setup an auto page refresh. Now, we do have some caveats:

  • List must be sorted so Newest item is always at the top.
  • Users must NOT be allowed to change that.
  • If the site is slow, the page may perform 2-3 (or more if really slow) automated page refreshes.
  • Test and act in kind.
  • The WorkFlow column must be visible

So that being said, the JavaScript.

Include a Content Editor WebPart on the page, use the Source Editor to paste in the code. NOTE: you will have to adjust the column (td:nth-child(3)) to match what you have in your list.

Basically, the script just checks for “In Progess” in the WorkFlow column, waits for 1 second and refreshes the page. The 1 second pause helps reduce multiple refreshes.

About the Selector:

.ms-listviewtable: I used a class as the ID was crazy long and gave me some issues. If you have more then one of these on your page, beware it will check all of them.

tr:nth-child(2): Move to the 2nd row. The 1st row is the Header (column titles).

td:nth-child(3): Move to the 3rd Column. (You will probably need to adjust this) This column will have a header value of the WorkFlow name.

a span: The text is wrapped in an anchor and span tag.

The Script:

<script type="text/javascript" src=""></script>

<script type="text/javascript">
      var td = $(".ms-listviewtable tr:nth-child(2) td:nth-child(3) a span").html();
      if(td=="In Progress"){
function sleep(ms)
      var dt = new Date();
      dt.setTime(dt.getTime() + ms);
      while (new Date().getTime() < dt.getTime());

And this does nicely for my needs. Hope it helps someone!

.htaccess mime type for .jar .jad .cod files for over-the-air Blackberry installs

Posted in Blackberry, Java with tags , , , , , , on September 29, 2011 by drew

This is mostly self documentation.  If you find this useful then great!

To install a Blackberry app over-the-air you will need these mime types in your .htaccess file.  Or if you are using IIS you will need to use the IIS Management snapin to add them.

AddType text/ jad
AddType application/java-archive jar
AddType application/vnd.rim.cod cod

And, upload the “deliverables\Web\X.0.0” files not the “deliverables\Standard\X.0.0” files.  Not sure why/how/what but I kept getting the dreaded 907 invalid cod error message otherwise.


Empire Avenue: Just another Social Network?

Posted in Social Media with tags , , on June 20, 2011 by drew

First off, I’d like to make a response to a premise I wrote about a few months ago: Set it and leave it on Empire Avenue.

No, You cannot just “set it and leave it”. Empire Avenue has made the on-site interaction a large part of the “scoring” that my original premise didn’t quite work. In a sense you can just leave it. But your score will suffer from the neglect. I doubled my score when I got serious with it.

Ok, now for my next premise!!! <drum roll please>

Is Empire Avenue just another social network?

Hmm? is it? A lot of people quote the hype of how they are connecting and defining new relationships and partnerships and Empire Avenue is different from the rest.

Time will tell.

Every social network was IT when it first arrived. Empire Avenue could be just another one of those. There is just one variable, in my humble opinion, that can set Empire Avenue apart from the rest for a long time to come: Empire Avenue consumes other networks.

I think this is the key that will keep people coming back to Empire Avenue. No matter how many other Social Networks emerge, people will invariably come back to the Avenue to see how their interactions rank against others. Only if the great folks at Empire Avenue can keep up the relevancy of how they score social networks can they keep ahead of the others.

And that is all for now.

ASP.NET CodeFile versus CodeBehind

Posted in asp, web development with tags , , on April 18, 2011 by drew

1 up for the guys at Microsoft. They thought of every eventuality it seems.

I was stumped for a while on a weird error:

2011-04-18 10:52:34,416 [11] ERROR 4/18/2011 10:52:34 AM Error occurred: System.Web.HttpException (0x80004005): The file Page.aspx.vb does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ProcessCodeFile(VirtualPath codeFileVirtualPath)
at System.Web.UI.TemplateParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData)
2011-04-18 10:52:34,416 [11] ERROR 4/18/2011 10:52:34 AM Stack Trace: at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ProcessCodeFile(VirtualPath codeFileVirtualPath)
at System.Web.UI.TemplateParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData)

What was odd was that I was using a compiled, updateable application. Why on earth was it trying to reference the code behind when everything is dumped into a .dll file?

Turns out we have the CodeBehind and CodeFile attributes of the @Page directive… Nice one Microsoft! So even though the rest of the application runs from the dll I can change one page to still run from an un-compiled .vb file by changing CodeBehind to CodeFile!!

Hope this helps someone else who inherits a project with that directive changed on only one page.


Force complete user sign-out in SharePoint 2010 using SharePoint Designer

Posted in javascript, jquery, SharePoint, web development with tags , , , , on January 27, 2011 by drew

I came across a common situation today where users are not completely signed out.  To recreate the issue, Log into a SharePoint site, open at least one more tab, sign out, then click back or re-navigate to the site.  You won’t have to type your credentials to browse the site.

Thanks to this Microsoft forum post by, we can use some JavaScript to ensure the user is completely Logged Out.

My problem, is I have a hosted SharePoint installation so I can’t modify the “_layouts/signout.aspx” page.

So here we are:

  • Fire up SharePoint Designer.
  • Edit the v4.master Master Page.
  • Add the following jQuery CDN link to the bottom of the <head> tag.
    <script type="text/javascript" src=''></script>
  • Add the following line of JavaScript
  • Under the Site Pages, Create a new aspx page called logout.aspx and style it like the original signout.aspx or create your own style.
  • Add the following code:
    function _spBodyOnLoad()
     catch (e) { }
  • And your ready to go!

Of course, your installation may or may not be slightly different, etc, etc so adjust IDs accordingly if needed.


ASP.NET MVC 2.0 Routing – First Experimentation

Posted in web development on September 19, 2010 by drew

I’ve done file -> new on a few ASP.NET MVC 2.0 projects now, but nothing in earnest yet.  Nothing that I would eventually publish to the interweb.

Until yesterday.

I’ve finally decided to build my first Web 2.0 application built on ASP.NET MVC 2.0.  Complete with accessible forms, Pretty looks, Awesome AJAX that falls back gracefully, etc, etc, etc.

This site will probably be the death of me.  I’m counting the days until I get hate mail and death threats. The site: Online Bible Queries with social commenting on passages.  Yup, I’m going to let people discuss, live, the most controversial book ever.  The one book that consistently finishes as the #1 best seller ever year.

So, before I got into the project 3 hours I was writing routes.  Of course, the first basic route was there:

"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {
controller = "Home",
action = "Index",
id = UrlParameter.Optional
} // Parameter defaults

Great, but that didn’t help me with a Version – Book – Chapter – Verse scenario. Did it?

So, I soon ended up with this:

new {
controller = "Search",
action = "Index",
Version = "King James",
Book = "Genesis",
Chapter = UrlParameter.Optional,
Verse = UrlParameter.Optional
} //defaults

Worked ok, but failed when the url was missing the Chapter and verse.
Moving it above the default route worked, but then it matched EVERYTHING including the /Home/Index, etc.

Making it less greedy did the trick.  I’ve read alot about not using greedy routes but I didn’t quite get it until I tried it. Go figure.

routes.MapRoute( //Route for AJAX that returns JSON Result
new {
controller = "Search",
action = "Query"

 routes.MapRoute( // Route for normal web browsing
new {
controller = "Search",
action = "Index",
Version = "King James",
Book = "Genesis",
Chapter = UrlParameter.Optional,
Verse = UrlParameter.Optional
} //defaults

Playing with the routes really helps understand the concepts of not just MVC Routing, but MVC in general.

I’m sure I’ll be working on these routes more in the future and no doubt they can be re-factored even more.

A unique twist in the social networking landscape

Posted in web development with tags , , , , on September 2, 2010 by drew

John Gushue recently wrote about the up and coming social networking site

I must say I agree with pretty much everything John has to say, including his initial reaction and expectations. There is one I’d like to add:

The basic premise of Empire Avenue isn’t predicated entirely with spending time on, but rather how much time you spend on other sites, like Facebook, Flickr, twitter and others sure to come.  While John stated this fact, I think it bears more thought.

Most, if not all, social networking sites require you to spend time on them.  Facebook is probably one of the biggest time wasters.  Twitter not so much.

EmpireAvenue simply rates your participation on other sites.  I’m sure there are those who spend precious little time on EA and still have a climbing “share” price.

Personally, I think this will be the factor that determines the success of EA.  I can ignore it for a month but still have people investing in me if I keep my active status in other sites.

So, what do you think?

Is Empire Avenue any different from other social networking sites or just the next fad site in a long list?

MS 70-542 Exam Guide

Posted in web development on September 1, 2010 by drew

Wanted to share this link: The Best 70-542 MOSS 2007 Exam Guide

I’m preparing to write the exam for the Microsoft SharePoint Certification and this information is great. Adam lays out the material exactly as the Exam matrix is presented so prepping should be a snap!

<edit for auth>


JavaScript can play nice with Accessibility

Posted in web development on August 30, 2009 by drew

So, web accessibility is a big topic these days.  And right so!

Developing websites that meet W3C Standards and proper accessibility make a better web for everyone.  Now, if we could only get MS, Google, Mozilla, Opera, Safari et al to use ONE, (1), UNO rendering engine we’d all be happier! But don’t get me started…..

Ok, so say we have a link, simply pointing to so, page2.html.  The link text is MenuX, and page2.html has a menu list of inner pages.  Fine and dandy, but unnecessary in today’s world of drop downs, mega menus, etc. Right?????

Wrong I say! This setup is PERFECT for SEO, SEM and every other SE* acronym you want to through around.

Now on to jQuery!


This will remove the HREF attribute from the link for us. It is important to note this is done after the browser has loaded with jQuery’s .ready() function. Search Engines won’t parse the JavaScript and hence will follow the original link. Browsers without JavaScript enabled like Screen Readers and such will follow the original link as well.

Now, we just use

$("#mylinkid").bind('' function() {/*do stuff*/});

to create our JavaScript enhanced functionality!

I mostly use this for AJAX scripts. For example, I needed a Calendar Widget for a website. I initially built the widget to use simple html anchors with a post back on each click. Once that worked, I overrode all that clunky functionality with nice speedy AJAX effects. Now, JavaScript or no, the calendar works. See for an example of this functionality.

Avoiding split words when truncating text

Posted in asp, optimization, web development with tags , , , , , , on August 21, 2009 by drew

In today’s world of widgets, dashboards and snippets, as programmers we often find ourselves truncating text.

I was doing some work on a classic asp website today and noticed the truncating was often mid-word.

This was my quick fix.

	dim sp, txt
	sp  = instr(10, rs(&quot;news_Text&quot;), &quot;.&quot;)
        txt = left(stripHTML(rs(&quot;Text&quot;)),sp)
	if sp  60 then
		sp = instr(50, rs("Text"), " ")
		if sp &gt; 60 then
			sp = InStrRev(rs("Text"), " ",70)
		end if
		txt = trim(left(stripHTML(rs("Text")),sp)) &amp; "..."
	end if


  1. Look for period after the first 10 characters and if so, use that as our snippet.
  2. If the Period wasn’t found, or after 60 characters, check for a space (end-of-word) after 50 characters.
  3. If the space is greater than 60 characters, find the first space in reverse, starting at 70 characters.

Of course, this still leaves out a few possibilities, but suffices for input that has some relatively safe input validation. It could be beefed up easily with a few more safeguards in terms of 1) no spaces, 2) special characters, 3) check for space after period, e.g a.m or p.m., 4) other requirements based on what kind of text you may be truncating.