Friday, April 15, 2011

JavaScript Code Snippet: Find and Replace all

Here is a JavaScript code snippet for a find and replace all.

This example code finds if there is an instance of three dashes in the string and replaces with three spaces.


if(str.indexOf('---') != -1){
str = str.replace(/---/g,' ');
}

Monday, February 21, 2011

New Photo Viewer

I've been playing with a new JQuery Photo Viewer control called Cloud Carousel written by Professor Cloud

This new control has helped me learn about image resizing as well, which has helped me shrink the size of the banner image improving performance.

Check out my Gallery here: http://dalecox99.com/Fun%20Stuff/photos.aspx

On the Photo Page I created a new master page that give the maximum view window to see all the photos.

I hope you enjoy the photos.

Tuesday, January 25, 2011

Silverlight Unit Testing Framework

I have to admit I haven’t dug into a lot of automated testing because of so much of my work being based on User Interface and asynchronous calls but I came across this Testing frame work and it looked pretty interesting as it simulates the user environment including the asynchronous capabilities, http://www.jeff.wilcox.name/2009/03/asynchronous-testing/ .

Friday, January 7, 2011

Excel Cell Formating

A little reference Gem about formatting cell values, related to my post about Exporting to Excel.

On occasion the format of the Cell will need to be specified. In my case I needed to preserve leading zeros on the record.

Evidently I don’t know the right search terms to find out where this is documented but after a rather long search I found that to get the text format I needed to use cell.NumberFormat = "@";

Many Thanks to today4me over at dreamincode.net http://www.dreamincode.net/code/snippet1218.htm for posting this little guide on formatting. I would have never guessed the @ symbol for the format.

Tuesday, November 2, 2010

SharePoint 2010 Work Flow (WF) Quick Hits

SharePoint Work flows are pretty strait forward for the most part but there are a couple items that are worth remembering. Some of them I have had to learn twice so this list I’ve made to review before I do WF implementations, in an effort to not have to learn things a third time :)

These notes are specific to Work Flows in SharePoint Designer.

1. Always save then publish.

2. If you have a test page open after the WF has been updated reload the page before initiating the WF. SharePoint will force you to do this anyway but you can lose any changes you made to test the WF.

3. When sending an e-mail via WF using a look-up person value select e-mail address, semicolon delimited for the look-up value.

4. In general, if you are using a look-up values in the WF verify it is not empty (Null) before using. If the error, Coercion Failed: Input cannot be null for this coercion, it is because a field has a null value or is empty. The Fix is to use the conditional IF-Else construct to check for Null before executing the actions, example: IF field is not empty.

5. A record seems to only be updateable by a WF once.

6. Conditional statements like IF-Else don’t move up and down so well in the WF step.

7. To create a state machine using a WF
a. Create a list or column to contain a copy of the field(s)
b. Seed the field with a copy of the content
c. Create a WF that accounts for the following conditions
d. Initial creation of the list item
i. Might be necessary to seed the list or column
e. On value change account for the following conditions
i. Different Content -> Previous Content is different
ii. Different Content -> Previous Content was Blank
iii. Current Content is Blank - > Previous Content was not
iv. Blank -> Blank
1. No action should be required as the state did not change
f. For an example / more information on how to do this see this link: http://office.microsoft.com/en-us/sharepoint-designer-help/watch-this-run-a-workflow-when-a-specific-field-changes-HA010256419.aspx

8. Hyperlinks made in the WF e-mail editor can be copied and pasted but the pasted version may need the link to be adjusted. Look-ups used in the e-mail editor cannot be copied and pasted.

Monday, October 11, 2010

Silverlight User Control Navigation Solution

There are two solution approaches when implementing a navigation solution, the capability to navigate between pages using Silverlight. One approach is to use user controls and is what this write-up focuses on the other approach which was recently added in Silverlight 4. For the most part this is a summary of the demo video provided by Jesse Liberty from Microsoft.

Steps for Creating a User Control Navigation solution
1. Create Silverlight Application
2. Add a new page called NavigationFrame
a. Delete the Grid control LayoutRoot in the NavigationFrame.xaml file
b. In the code behind file add the code below to the constructor to load a default page in this example it is the main page

if (this.Content == null)
{
this.Content = new MainPage();
}

c. Add a navigate method to change the content displayed in the page

public void Navigate(UserControl nextPage)
{
this.Content = nextPage;
}

3. Update the App.xaml.cs to load the NavigationFrame Page instead of the MainPage on Application load
a. In the Application_Startup method change MainPage to NavigationFrame
4. Create another Silverlight page called Page_2
5. Add navigation Controls
a. In my case I am using buttons for navigation and added them to both pages (MainPage and Page_2)

<button name="buttonSwitch" type="submit" width="75" content="Switch" height="23" horizontalalignment="Left" margin="132,212,0,0" verticalalignment="Top" click="Switch_Click">

6. In the code behind of both MainPage and Page_2 the even handler needs to be added to swap between the target pages
a. Example of code behind for Page_2

private void Switch_Click(object sender, RoutedEventArgs e)
{
NavigateFrame ps = this.Parent as NavigateFrame;
ps.Navigate(new MainPage());
}





Reference: User Control Implementations
Jesse Liberty Demo Video - http://www.silverlight.net/learn/videos/silverlight-videos/using-multiple-pages-part-1/
Slightly Different implementation use a service approach- http://nerddawg.blogspot.com/2008/06/pages-in-silverlight.html
Similar example - http://www.c-sharpcorner.com/UploadFile/nipuntomar/Silverlight07082008154003PM/Silverlight.aspx

Navigation Application (SL4)
Basic implementation write up- http://www.silverlighttoys.com/Tutorials.aspx?tutorial=1
Detailed write-up - http://stuff.seans.com/2010/05/07/silverlight-4-project-types-part-ii-%E2%80%93-silverlight-navigation-application/

Thursday, October 7, 2010

JQuery Resources

With the recent uptick in JQuery as a go to client side technology, I wanted to share these resources I recently found.

This is a nice article describing the role of JQuery and ASP.NET as well as some well-founded conjecture on the future of Microsoft support of JQuery.
http://visitmix.com/Articles/Javascript-Libraries-and-ASPNET

This is an online training guide, I’ve only skimmed the content but it looks like a fantastic resource.
http://jqfundamentals.com/book/book.html