Tag Archives: Development

SharePoint 2010 Sneak Peek !!!

Today Microsoft released some great videos highlighting the potential of the next release of SharePoint.    There is some excellent material here include a full walk through showing live products in action.

http://sharepoint.microsoft.com/2010/Sneak_Peek/

image

 

Overview

  • Tom Rizzo, speaker
  • Robust cross browser support
  • AJAX calls for faster page loads
  • SharePoint Designer 2010 – Streamline interface, robust BDC features.    No more Lightning Tool BDC Metaman?
  • SharePoint Workspace 2010 – Take lists and documents offline with a better than ever Groove client
  • BCS is the new BDC
  • Rich integration with Office 2010 – Sample BCS populated memo to regional sales representative.

image              image 

IT Pro

  • Richard Riley, speaker
  • Professional productivity, Scalable platform, Flexible deployment
  • Release timeline
  • Central Admin cleaned interface.   Similar to Control Panel in XP from Windows 2000.  
  • Robust Logging.   New dedicated database, runs BPA (Best Practice Analyzer) to give suggestions, granular detail never seen before.   “Slowest Pages” insight.
  • Visual Upgrade.    Allows site owners and users to preview before decided to switch browser interfaces.

image

Developer

  • Developer productivity, Platform services, Flexible deployment
  • Developer dashboard.   Site feature provides browser output with detail rendering stack.  
  • Visual Studio 2010  – MUCH improved developer experience.    Detailed build options and project types.
  • Visual web part designer.
  • LINQ for SharePoint API
  • Client Object Model (OM) available in Silverlight and JavaScript.
  • Write quality solutions in less time.

image

URL Source= for Thank You on Submit

Many times I’ve been asked to adjust the NewForm.aspx (add record) experience for users to display a custom message after submit.    A “Thank You” page for a survey is a great example.    Other times in request forms people want to show a confirmation or instructions page.

Thankfully the SharePoint product team made this easy for us developers.

Action Steps

  1. Visit the list or library you’d like to tweak
  2. Click on New item to get to /NewForm.aspx
  3. Take a close look at the URL and notice the word “Source=”
  4. We’ll come back to this in a minute
  5. To create a “ThankYou.aspx” page I like to duplicate the “DispForm.aspx” by going into SharePoint Designer
    1. Right click Copy on DispForm.aspx
    2. Right click and Paste
    3. Edit the file to remove the main web part
    4. Rename the file to “ThankYou.aspx”
  6. Edit the part after the equals sign (=) from #3 and replace with a URL you’d like to take people to after submit

 

Often the destination page for #5 above doesn’t yet exist.   So you’ll want to open SharePoint Designer 2007 and create a new ASPX page to hold a “Thank You” message.    For this I always place the ASPX file in the same /Forms/ folder as the list I’m working on.   

Why?    By placing a custom ASPX in the same /Forms/ folder it will be including in any List template (.STP) creation and is easier for future admin and dev staff to locate for troubleshooting.

 

 

image

 

image

 

image

 

image

image

 

image

 

image

 

image

 

image

 

image

 

image

 

image

Save C# Time with .OpenWeb()

One of my most common coding task is a simple command line EXE that takes a few parameters in, opens the object model, and applies some sort of changes.   Yes, I know about PowerShell, but am very comfortable with Visual Studio and Intellisense today.

Action Steps

  1. Start a new “Console Application” project type
  2. Add an assembly reference for “Microsoft.SharePoint.dll”   (12.0.4518.1016)
  3. Type “SPSite s” and right click to add the “using” statement.   Very nice shortcut, thank you Joel G!
  4. Create a new SPSite object and use the full URL to the web for the constructor
  5. Use the SPSite.OpenWeb()  method to grab that one web object without the hassle of looping through children
  6. This trick works no matter how far the SPWeb is nested down in the site collection

 

image

image

 

image

 

image

 

image

 

image

Coding EventLog Excellence

Summary

It’s a best practice to have all custom code write to the event log.   Every code execution should produce one and only one log entry.   Exceptions (code speak for err) should be written here.    For troubleshooting and support you can’t ask for a better tool.    The framework exists, EventCombMT helps aggregate, and it allows you to run dozens … or hundreds … of apps while keeping a sharp eye on quality control.

Namespaces

System.Diagnostics.EventLog

Example

clip_image002

 

static void Main(string[] args)
{
    try {
        //Main code procedure
        Console.WriteLine("Hello World!");
        writeEventlog(1, null);         //Write to Eventlog – GOOD 
    }
    catch (System.Exception e)
    {
        writeEventlog(2, e);            //Write to Eventlog – BAD
    }
}
static void writeEventlog(int success, System.Exception e)
{
    //Current EXE name
    String exe = System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(‘,’)[0];
    String header = "";
    String exception = "";
    EventLogEntryType type = EventLogEntryType.Information;
   
    //Determine type
    switch (success)
    {
        case 1:
            header = "nOperation successfully completed";
            break;
        case 2:
            header = "nOperation FAILED";
            if (e != null) strException = e.Message + e.InnerException + e.StackTrace;
            type = EventLogEntryType.Error;
            break;
        case 3:
            header = "nOperation WARNED";
            if (e != null) exception = e.Message + e.InnerException + e.StackTrace;
            type = EventLogEntryType.Warning;
            break;
    }
 
    //Write to log
    EventLog myLog = new EventLog("Application", ".", exe);
    myLog.WriteEntry(exe + "n" + exception, type);
}

MOVIE – Random Tip – XSLT

So you want to display a single random item from a SharePoint list?     It’s a common request and a very handy one for visitors.    Give your site a fresh relevant appearance with a dynamic web part.    Web 2.0 requires us site designers to keep pace with visitor expectations.   Let’s get to the fun part.    Here we’ll be using the Data Form Web Part (DFWP) sometimes called the Data View Web Part (DVWP) to present a SharePoint list with XSLT logic for the randomizer and conditional formatting to only show the target record.

Example Code   (random row XSLT.txt  1KB)
Sample Data     (Email Security Tips.xls  13KB)

 

Watch this 4 minute movie clip to see a live demo.     Steps are outlined below also.

 image

 

  1. Create your list
  2. Open the target page in SharePoint Designer 2007
  3. Open Data View Manage Data Sources
  4. Ctrl+Click the Title and Body columns     (NOTE – other column names work too)
  5. Drag them on the page
  6. Add two CSS classes to the page header
  7. Locate the XSLT header with “<xsl:variable” entries and confirm you have the below three:
     
     
    
  8. Locate the <TR> for starting a new row.   Add the conditional pair below to apply the right CSS class when needed.
    
         
            showMe 
         
         
            hideMe 
        
  9. Apply extra formatting  (bold, colors, icons) to achieve a unique look for your audience.

JQuery Accordion – Expand Collapse All

I looked over many threads and posts on many sites and wasn’t able to find code that worked for me.    Some of it would be close.   Others buggy.   Below I’ve outlined the JQuery code that worked perfectly for my needs and I hope you find it helpful too.

This example was deployed to a SharePoint page so the “/_layouts/images/plus.gif” was used to leverage the OOTB graphics for a plus/minus icon feel.

Full Example Source Download     (accordion.zip  73KB)

 

image

 

image

 

Parent .HTML

Expand All

First Header

first body

Second Header

second body

Third Header

third body

Supporting .JS

// bind to accordion object
$(document).ready(function(){
	$('#container').accordion({
		header: “h3?
	});
});
// actions taken upon clicking the expand all (collapse all) link
$('#container #expand').click( function() {
	// if link was expand then show and toggle text
	var currHTML = $('#container #expand').html();
	if (currHTML.indexOf(“Expand All”)>0) {
		$('#container .section').slideDown();
		$('#container #expand').html(“ Collapse All”);
	} else {
		// if link was collapse then hide and toggle text
		$('#container .section').slideUp();
		$('#container .section').each(function(i){
			if (i==0) $(this).slideDown();
		});
		$('#container #expand').html(“ Expand All”);
	}
});
Return to Top ▲Return to Top ▲