Tuesday, April 26, 2011

Adding a stylesheet to a SharePoint masterpage using the CSSRegistration control

Sharepoint has a .NET control for registering CSS files in a SharePoint masterpage called SharePoint:CSSRegistration. Use the ~Site token to specify the current site. This control goes in the head section of the masterpage.

<SharePoint:CssRegistration name="<% $SPUrl:~Site/CSS/gilariver.css%>" runat="server"/>

New to SharePoint 2010
You can specify the order using the After property. The After property contains the name of the CSS that you want to place the CSS after. The ConditionalExpression parameter will tell the CssLink to render the Conditional-CSS code as well as the CSS link.

Using the RadCaptcha control

RadControls has a RadCaptcha control that can be used in .NET applications or SharePoint web parts. Add the RadCaptcha image handler to the web.config file to use the captcha:

<system.webServer>
...
<handlers>
...
<add name="Telerik.Web.UI.WebResource" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2010.3.1317.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
...
</handlers>
</system.webServer>

Wednesday, April 6, 2011

SharePoint List displayed in XML using OWSSVR.dll

OWSSVR.dll will, among other functions, return the XML data of a SharePoint List. The format of this utility is:

http://yourserver/yourweb/_vti_bin/owssvr.dll?Cmd=Display&List={guid}&XMLDATA=TRUE

http://webcs10.cgc.maricopa.edu/student-affairs/athletics/athletics/_vti_bin/owssvr.dll?Cmd=Display&List=5C1E1425%2D8F8E%2D4427%2D8B4A%2D1A97748B4AD6&XMLDATA=TRUE

More information can be found here:

http://msdn.microsoft.com/en-us/library/ms478653.aspx

Tuesday, January 4, 2011

Dynamically changing Frameset dimensions

There may be a need to dynamically change the dimensions of an HTML Frameset in the DigitalSignage system.

If we have a frameset defined:


<frameset id="mainFrame" border="0" rows="25%,70%,*">
<frame border="0" noresize="noresize" src="header.html" />
<frame src="" scrolling="no" frameborder="0" />
<frameset border="0" cols="25%,50%,*">
<frame src="footer1.html" scrolling="no" frameborder="0" />
<frame src="footer2.html" scrolling="no" frameborder="0" />
<frame src="weather.aspx" scrolling="no" frameborder="0" />
</frameset>
</frameset>

Below is an example of javascript that varies the dimensions of the rows:

parent.document.getElementById('mainFrame').rows='0%,95%,*';

With this code we're hiding the top row by setting the height to 0%.

Tuesday, December 14, 2010

TextBoxCounter control by skmControls

In programming a textarea for a web application, I had the need to display to the user the amount of characters to go before the maximum length of the textarea was reached. I found a .NET library on line called skmControls2.dll that provides a textBoxCounter control. Documentation can be found at:

http://scottonwriting.net/sowblog/codeprojects.htm

Below is an example of the use of the control with some of its properties:

TextBoxCounter tbc = new TextBoxCounter();
tbc.TextBoxControlId = commentBox.ID;
tbc.TreatCarriageReturnsAsOneCharacter =
true;
tbc.MaxCharacterLength = 500;
tbc.DataFormatString =
" Characters entered = {1}.";
tbc.CssClass =
"CharacterNorm";
tbc.WarningPercentage = 95;
tbc.CssClassForWarning =
"CharacterWarn";

Friday, October 29, 2010

SharePoint's _spBodyOnLoadFunctionNames function

The Body onLoad event for the SharePoint master page runs the _spBodyOnLoadFunctionNames function. If you need to run any other javascript at page load, push function name this function. As an example:

function setSearchBoxFocus() // set focus to search textbox
{
document.getElementById('ctl00_ctl00_SearchBox_S3A1EF0A8_InputKeywords').focus();
}

_spBodyOnLoadFunctionNames.push("setSearchBoxFocus");

Wednesday, October 6, 2010

Adding scripts or styles to SharePoint master pages

There are times you may need to add a script or a style to the <head> tag of a CGCC public or Inside webpage. In each SharePoint Master page (except CGCC-Parent.master) there is a content placeholder named 'PlaceHolderAdditionalPageHead' that looks like this.

<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" >
</asp:ContentPlaceHolder>

In your aspx layout page, add the following asp:Content control:

<asp:Content ContentPlaceholderID="PlaceHolderAdditionalPageHead" runat="server" >
</asp:Content>

Place the script or style in between the opening and closing tag. After saving and publishing, go to the website and verify.