Posted by: Gabe Hilado in jQuery,SharePoint on October 30th, 2009

It’s that time of the year again when kids will be kids and grown-ups can be kids. I’m talking about Halloween. Halloween is one of the more festive events in the year, in my opinion. You have tons of candies, parties everywhere, and costumes galore. When it comes to costumes, there are some people who really dress-up.  And then there some who simply don a mask for their Halloween costume. Masking is the inspiration for today’s post: input-masking in SharePoint Forms.

Input-masking is a programmng technique which allows applications specify the rules for the data-inputs. For example, ZIP codes should be 5-digit numeric number or phone numbers should be numeric (mostly) and appear in the form of (111) 555-0000. In SharePoint, you will see fields in some forms that should have a mask for the input. Take the Contacts List as an example: a contact has phone numbers and ZIP code. Yet, SharePoint doesn’t validate what users input in those fields. Take a look:

Invalid format for phone-number in SP Contact Form

Invalid format for phone-number in SP Contact Form

SharePoint allowed invalid phone number

SharePoint allowed invalid phone number

If SharePoint site-definition forms will not enforce input-masking, we can easily apply it ourselves using jQuery JavaScript library. You can dowload the jQuery jlibrary here. (You can link to jQuery library from one of the Google sites; I only recommend you download the js file itself in the event you’re running your development sandbox in an isolated network). You will also need to download the input-mask  jQuery plugin. Upload the jQuery js file and the input-mask plug-in (another js file) into a “scripts” library in your SharePoint site.

Open-up the SharePoint Site and edit the list’s NewForm.aspx or EditForm.aspx in SharePoint Designer. In this example, we are editing the Contacts List EditForm.aspx. You want to look for the table element whose ID is onetIDListForm. Insert the following code just below the table.onetIDListForm element:

<script src="../../scripts/jquery-1.3.2.js"></script>
<script src="../../scripts/jquery.maskedinput-1.2.2.min.js"></script>
<script type="text/javascript">
 $(document).ready(function() {
 $("input[title='Business Phone']").mask("(999) 999-9999");
 $("input[title='Home Phone']").mask("(999) 999-9999");
 $("input[title='Mobile Phone']").mask("(999) 999-9999");
 $("input[title='ZIP/Postal Code']").mask("99999");
 });
</script>

I will write another blog-post about jQuery. For now, I will quickly explain what the code above does. $(“input[title='Business Phone']“) selects the text-box for the Business Phone field. There are different ways to select elements using jQuery. What I did above as select the input whose title is “Business Phone”. After the element has been matched, we call the plugin’s Mask() method. Why not select the input-element using the ID? Because you do not know nor control what ID value will be generated by SharePoint. The typical input element generated by SharePoint looks like the following:

<input name="ctl00$m$g_d1b9fb52_9f94_4f65_b370_2c23efb30c7e$
             ctl00$ctl04$ctl08$ctl00$ctl00
             $ctl04$ctl00$ctl00$TextField"
       type="text" maxlength="255"
       id="ctl00_m_g_d1b9fb52_9f94_4f65_b370_2c23efb30c7e_ctl00
             _ctl04_ctl08_ctl00_ctl00_ctl04_ctl00_ctl00_TextField"
       title="Mobile Phone" />

Selecting the input-text using the title attribute is easier and will be consistently rendered by SharePoint that way anyway (assuming the list column stays the same and doesn’t get modified.)

After the masks have been applied, the SharePoint Contact form will now ensure that the inputs conform to the phone number and ZIP code format:

Input-masks in a SharePoint Contact Form

Input-masks in a SharePoint Contact Form


I haven’t had a chance to blog about jQuery yet but I will do this sometime next week. jQuery is a very useful and powerful JavaScript library. There are many other tricks you can do in SharePoint with jQuery and I will discus them next week.

I hope you guys enjoy Halloween tomorrow. And don’t eat too many candies!

Posted by: Gabe Hilado in SharePoint on October 26th, 2009

When Windows 7 came out last week, I decided to go ahead and install it on my laptop. I like what I see so far–everything seems to run faster in Windows 7! Same hardware; the apps just launch faster. For example, SharePoint Designer used to take 5-10 seconds to launch when it was Vista. Now, I can get SharePoint Designer to run in 2 seconds. Visual Studio 2008 used to be 5-10 seconds to launch as well. Now Visual Studio 2008 opens up like I’m opening Internet Explorer! Now, I’ve always ran SharePoint in a Windows Server 2003 virtual machine. And it was decent performance. But now that I’m seeing Windows 7 to be more efficient, I thought, what if I just ran SharePoint (MOSS) in Windows 7, forget about running it in a virtual machine?

I found this walkthrough from Bamboo Solutions on how to install SharePoint on Windows 7. It worked and all I can say is wow! Now, there were two issues that I ran into when I tried to follow the walkthrough. First issue I ran into was is making the boot-strapper launch the MOSS installer. I have the original media from 2007 and no matter how many times I tried to make Bamboo Solution’s setup-helper launch that setup.exe, it wouldn’t launch it. The error message that I got was:

wssOnVistaIssue1

WSS on Vista - Setup Controller Command Line Help

I tried renaming the setup.exe file to SharePoint.exe, thinking maybe, just maybe the setup-helper is file-name dependent. It didn’t work. Finally, I decided to just go ahead and download the trial version of  MOSS (if you have proper license):

If you don’t have MOSS license, just download WSS 3.0. If you have MOSS license, you can enter your key during the installation to make the installation permanent. I tried x64 MOSS 2007 trial with the Bamboo helper and it worked.

One more issue I ran into was when I ran the SharePoint Configuration Wizard for the first time. It said that I don’t have IIS installed. Well, I already had IIS running–IIS 7. When I picked the Windows feature to install, I did not select the IIS 6 Management Compatibility:

Turn on IIS 6 Management Compatibility in Windows Features

Turn on IIS 6 Management Compatibility in Windows Features

The moment I turned on IIS 6 Management Compatibility, the SharePoint Configuration Wizard was able to proceed.

I’m very happy with my laptop setup now. I have MOSS running on it and I don’t even need a virtual machine anymore. Do I think it’s risky to install MOSS on my base OS? I don’t think so; I’ve been installing and running SharePoint since 2007 and I have yet to see it mess up the operability of an application or service in Windows. But then again, I’ve always used Windows 2003 Server. Who knows what kind of issue I will run into running MOSS on top of Windows 7.

As much as I recommend you guys trying MOSS/SharePoint on Windows 7, I highly recommend you run the upcoming SharePoint 2010 beta on a virtual machine only! When SharePoint 2010 Beta comes out next month, I will be running that inside a virtual Windows 2008 Server.

Posted by: Gabe Hilado in SharePoint on October 23rd, 2009

The SharePoint conference just concluded in Vegas. So many things being discussed right now with the upcoming SharePoint 2010. My friend Russell emailed me this article about SharePoint: SharePoint is Microsoft’s Real Window of Opportunity.

The article couldn’t have explained it better about the strategic importance of SharePoint. People think SharePoint is all about Web 2.0, collaboration, content management, etc. SharePoint is that but it’s NOT ALL that. You see, it’s all about protecting and promoting the Microsoft Office product line. Years ago, Open Office came along and gave people a free alternative to having software to create documents, spreadsheets, presentation slides, and email client. Microsoft Office cost money while Open Office was free–based purely on price-point, Open Office seemed like a no brainer. Then early versions of SharePoint came along; I thought the first versions were utter crap. Better “content management” systems came along, some of them open-source such that they were attractive to organizations with small budgets. Open source Web 2.0 such as Media Wiki and WordPress also came along. Fine products if I may say so myself. Meanwhile, Microsoft was busy improving Office, SharePoint, and the .NET Frameworks. This coming version of SharePoint integrates all of that together. Keyword is interoperability. The Office products (Word, Excel, Access, Outlook) integrate with SharePoint and .NET and .NET runs inside Office (macros and code-behinds) and in SharePoint (Web parts, features). Then there is the SharePoint Enterprise Search–if the organization was putting most if not all of their artifacts in SharePoint, people within the organization can find information regardless of whether the information resides in a Web site, a  Word document, a database, a blog, a wiki, etc.
 
Now, imagine getting Open Office as your productivity tool, Media Wiki as your wiki tool, and WordPress as your blogging tool, and then get some open-source search engine. Cost is zero dollars for software licenses so far. Add an open-source email client and mail server. The cost is still zero up to this point. Now integrate all that disparate technologies and maintain it over long term. Can you even integrate all that stuff at all? Say, they managed to integrate Open Office and WordPress and the integration breaks later on, who is responsible for the fix? In other words, who will provide support? Open Office developers? Or should that be the WordPress developers’ responsibility? Or is it the shop maintaining the integration (after all, they do have the source code)?
 
It will be very difficult to make all that open-source or “cheaper” alternatives inter-operate with each other. At the end of the day, SharePoint and Office is a one-stop-shop for everything–document creation and editing, sharing, calendars, tasking, blogging, knowledge management, forms, businss data, dash boards, and search.
 
SharePoint is like a Swiss Army knife–it has different things packaged into one. If each of the features of SharePoint is a tool within the Swiss Army knife, then one can say that technologies trying to compete with SharePoint are individual tools and they’re not together. Should an office always buy and implement the Swiss Army knife? No. If  it just needs a screw driver and nothing else, the bottle opener and the rest of the stuff is frivolous, So, that office is better off just “buying a screw driver”. To use SharePoint just for blogging is overkill. To use SharePoint just so there is a place to upload documents to is overkill. To use SharePoint just as a content management system is not getting your money’s worth. You get the point. If you just need blogging, just get WordPress. If you just need wikis, get MediaWiki. And so forth.
 
The article also points out that Google is the only closest thing to provide the “one-stop-shop” alternative to SharePoint. I’m not very familiar with this coming Google Wave just yet. All I know is that it’s going to be “cloud-based”. If it’s going to be an outsourced cloud, such that Google hosts the data and apps, a lot of big companies will shun from it. Amazon S3 is already out there yet you can’t use that cloud technology for everything; Amazon S3 fails to comply with financial standards/requirements (example: Amazon will tell you do not store credit card transactions in their platform). Sensitive corporate or national security stuff going to an outsourced cloud? Forget it; it ain’t gonna happen. Check this picture though–Google might allow companies to implement a private cloud:
 
http://www.waveprotocol.org/Home/federation_diagram.png?attredirects=0
 
We really don’t know what the cost will be to implement the Google way when it’s ready. We’ll find out soon enough. By the time Google or anybody can provide all that is provided by SharePoint, Microsoft would have sold many licenses at that point that they can give this product away for free. Oh, another way to say it is by the time Google or anybody else has figured it out, Office will be so entrenched everywhere that Microsoft can give away freebies.
 
Heck, if one looks at it, it seems Microsoft is already giving people a cheap alternative. Enterprise SharePoint (MOSS) is expensive, right? Well, you can get a zero-dollar-cost solution and still be in SharePoint. Here’s what you do:

  • Get SQL Server 2005 Express for free
  • Get WSS 3.0 from microsoft.com for free (if OS is Small Business Server 2008, WSS 3.0 is already there, for free)
  • Get Search Server 2008 Server from microsoft.com for free
  • Go to codeplex.com and get BlogEngine.NET for free to get enhanced blogging. Did I say it’s free?
  • Download Community Kit from codeplex.com for free and get an enhanced wiki engine.. Again, free.

The nice thing is that all of these will integrate together. The integration of all of the listed above comes close to MOSS but still missing a few features such as Publishing feature, Excel Services, InfoPath Forms Server, and Business Data Catalog. But all of that for free! Search used to be part of Enterprise MOSS. I couldn’t believe it when Microsoft started giving that stuff way for free! I can see Microsoft giving away more free stuff in the future there really is no point to going to an open-source alternative. Open-source developer Gary Edwards is worried. And rightly so.

Newer Posts »