Tuesday, May 4, 2010

HOW TO Display a "Printer Friendly" button on SharePoint pages

Insert the following code in a Content Editor Web Part to display a “Printer Friendly” button on SharePoint pages. When you click the button, it opens the SharePoint page in a new window. And the page will not contain the left and top nav bars. You are also presented with the list of printers that you can print to. And you can also do a Print Preview. This way you get to print only the content that you are really interested in, as opposed to the navigation menus, etc.

NOTE: In the code sample below, the jQuery file was stored in a SharePoint Doc Lib. You can also point to the Google site which hosts the jQuery file like this:

Credit:

http://web.iotap.com/Blogs/tabid/277/EntryId/82/Printer-Friendly-Page-Sharepoint-web-part.aspx

<script type="text/javascript" src="jQuery/jquery-1.3.2.min.js"></script>

<div>

<input id="printBtn" type="button" Value="Printer Friendly" alt="Print this page" style="margin-top:10px;margin-left:10px;"/>

</div>

<script>

$(document).ready(function()

{

var strlink="";

$("link[rel='stylesheet']").each(function()

{

strlink+="<link rel = 'stylesheet' href='"+$(this).attr('href')+"' type='text/css'/>";

});

$("#printBtn").click(function()

{

var htmlStr ="<html><head>"+strlink+"</head><body>"+$("#MSO_ContentTable").parent().html()+"</body></html>";

var PrintingWindow = window.open("about:blank","","toolbar,width=800,height=600,scrollbars,resizable,menubar");

PrintingWindow.document.open();
PrintingWindow.document.write(htmlStr);
PrintingWindow.document.close();
PrintingWindow.focus();
PrintingWindow.document.getElementById("printBtn").style.display="none";
PrintingWindow.print();
});

});

</script>

HOW TO Embed a Video file in a Content Editor Web Part

Insert the following code to embed a video file in a SharePoint Content Editor Web Part. Replace the ref value="" with the path to your video file.

<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer1" width="300" height="235">

<param name="URL" ref value="http://intranet.na.xxxx.com/sites/videos/pages/Profile.aspx?AssetID={1B89321E-E227-4FE5-978A-4D4CEF45FD7D}&DownloadFilePath=%5c%5cKFTUSOKTULAP110%5cTubeTarget1%5c2009%5c40%5c1b89321e-e227-4fe5-978a-4d4cef45fd7d%5cFile.wmv">

<param name="rate" value="1">

<param name="balance" value="0">

<param name="currentPosition" value="1">

<param name="defaultFrame" value=1>

<param name="playCount" value="1">

<param name="autoStart" value="0">

<param name="currentMarker" value="1">

<param name="invokeURLs" value="-1">

<param name="baseURL" value>

<param name="volume" value="50">

<param name="mute" value="0">

<param name="uiMode" value="mini">

<param name="stretchToFit" value="0">

<param name="windowlessVideo" value="0">

<param name="enabled" value="-1">

<param name="enableContextMenu" value="-1">

<param name="fullScreen" value="0">

<param name="SAMIStyle" value>

<param name="SAMILang" value>

<param name="SAMIFilename" value>

<param name="captioningID" value>

<param name="enableErrorDialogs" value="0">

</object>

Tuesday, March 9, 2010

ASPNET Regular Expression for validating Password field

Shown below is the Regular Expression to validate the following Password requirements:

 

·         Password is at least 7 characters in length

·         Password contains at least one non-alphanumeric character

 

 

<asp:RegularExpressionValidator ID="revValidatePwd" runat="server" ControlToValidate="txtNewPwd"

ErrorMessage="Password must be 7 characters in length and include one non-alphanumeric character."

ToolTip="Password must be 7 characters in length and include one non-alphanumeric character."

ValidationGroup="ChangePwdValidation" ValidationExpression="^(?=.*(\W)).{7,}$">*</asp:RegularExpressionValidator>                   

 

HOW TO Auto-populate field in custom SharePoint List Form using value from SQL database

Monday, March 8, 2010

SharePoint Ghosted vs Unghosted pages

An excellent post that demystifies SharePoint’s Ghosted and Unghosted pages:

http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=4