Call

Category Archives: Microsoft

Batch script to test if a server is responding using Ping

0
Filed under Microsoft

We were asked by a client to write a simple batch program that tests if a server is alive by using ping.

Below is a sample of the script that we created. The client used it in a Formscape project to ensure that a server was available before writting a record to a database using ODBC.

@echo off
CLS
:RETRYPING
echo Testing if 192.168.1.1 host is alive
ping 192.168.1.1 | find "Reply" > nul
if not errorlevel 1 (
echo Host is alive
) else (
echo host is down - retry in 30 Seconds 
REM Poor man's sleep function - ping localhost
ping 1.0.0.0 -n 1 -w 30000 >NUL
echo Retry now
GOTO RETRYPING
) 
:ENDPING

VB.NET Code Snippets: Updating a data source using an event

0
Filed under ASP.NET, Microsoft

You may wish to update a data source using an event.

'You need to use FindControl to access control on a  FormView:
Dim FirstName As TextBox = FormView1.FindControl("FirstNameTextBox")
Dim LastName As TextBox = FormView1.FindControl("LastNameTextBox")
Dim Phone As TextBox = FormView1.FindControl("PhoneTextBox")
Dim Email As TextBox = FormView1.FindControl("EmailTextBox")
SqlDataSource1.InsertParameters("FirstName").DefaultValue = FirstName
SqlDataSource1.InsertParameters("LastName").DefaultValue = LastName
SqlDataSource1.InsertParameters("Phone").DefaultValue = Phone
SqlDataSource1.InsertParameters("Email").DefaultValue = Email
SqlDataSource1.Insert()

And, this is the code for Update:

SqlDataSource1.UpdateParameters("FirstName").DefaultValue = FirstName
SqlDataSource1.UpdateParameters("LastName").DefaultValue = LastName
SqlDataSource1.UpdateParameters("Phone").DefaultValue = Phone
SqlDataSource1.UpdateParameters("Email").DefaultValue = Email
SqlDataSource1. Update()

“Rebranding” SharePoint using Content Editor Web Part and CSS

0
Filed under Microsoft, SharePoint

As discussed in the SharePoint: Hide View All Site Content and Recycle Bin Post. The same instructions can be adapted to hide other unwanted SharePoint content.

Below is a selection of CSS code that can be used to “rebrand” SharePoint using a Content Editor Web Part:

<style>
/* breadcrumbs */
.ms-titlearea {
  display: none;
}
/* Tabs */
.ms-banner {
 display: none;
}
/* Title Bar */
.ms-pagetitle {
  display: none;
}
/* Search function */
.ms-searchform {
display: none
}
/* Welcome and help stuff */
.ms-globallinks {
 display: none
}
/* Remove shadings from right */
.ms-sitetitle {
     background-color: white
}
</style>

How to: Install Windows SharePoint Services 3.0 Application Templates

0
Filed under Microsoft, SharePoint

Microsoft has provided 20 sample templates to use with Windows SharePoint Services 3.0.

The templates can be downloaded from Microsoft’s Download Center.

Run the download .exe file and extract the templates to a suitable folder on your WSS server (like C:\wss-templates).

From WSS Server, at command prompt run the the following:

cd\
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
stsadm -o addsolution -filename c:\wss-templates\ApplicationTemplateCore.wsp
stsadm -o deploysolution -name ApplicationTemplateCore.wsp –allowgacdeployment –local
stsadm -o copyappbincontent

To install a specific template, like Knowledgebase, run the following:

stsadm -o addsolution -filename c:\templates\KnowledgeBase.wsp
stsadm -o deploysolution -name KnowledgeBase.wsp –allowgacdeployment –local

Repeat the commands for any other templates you wish to install.

Details of all the templates can be found on TechNet.

SharePoint: Hide View All Site Content and Recycle Bin

0
Filed under Microsoft, SharePoint

Sometimes it nessary to hide View All Site Content and the Recycle Bin on a SharePoint page. This can be accomplished by using a Web Part, CSS and JavaScript.

Choose Site Actions, Edit Page.

SharePoint Edit Page

SharePoint Edit Page

Add a new Content Editor Web Part(in Miscellaneous) to the page.

Choose Edit, Modify Shared Web Part.

Modify Shared Web Part

Modify Shared Web Part

Put the following two code section into the Source Editor:

<style>
.ms-navframe {
  display: none;
}
</style>
<script language="JavaScript">
document.getElementById('onettopnavbar1002-1').style.visibility='hidden';
document.getElementById('onettopnavbar1002-2').style.visibility='hidden';
document.getElementById('onettopnavbar1002-3').style.visibility='hidden';
document.getElementById('onettopnavbar1002-4').style.visibility='hidden';
</script>

Choose the OK button and now the View All Contant and Recycle bin should disappear.

Exit Edit Mode to complete.

VB.NET: Retrieving Active Directory account properties

0
Filed under ASP.NET, Microsoft

The .NET Framework includes an API called System.DirectoryServices. The sample VB.NET code below shows how to retrieve user account properties from the Active Directory.

In order to use System.DirectoryServices classes, you will need to first add a reference to System.DirectoryServices.

Imports System.DirectoryServices is required at the very top of your VB.NET code.

Function GetUserProperties(ByVal GetUser, ByVal Result)
        Dim objSearch As New DirectorySearcher
        objSearch.SearchRoot = New DirectoryEntry("LDAP://dc=domain,dc=co,dc=uk")
        objSearch.Filter = GetUser
        'cn = Full Name, givenName = First name, initials = Middle names, sn = Surname, mail = email address
        objSearch.PropertiesToLoad.AddRange(New String() {"cn", "giveName", "initials", "sn", "department", "mail", "Manager"})
        Dim objResult As SearchResult
        objResult = objSearch.FindOne()
        GetUserProperties = (objResult.Properties(Result)(0))
End Function

Replace dc=domain, dc=co, dc=uk with your AD settings.

Free SharePoint Developement Training from Microsoft

0
Filed under ASP.NET, Microsoft, SharePoint

Module 1: SharePoint Development for .Net Developers

Module 2: Web Parts

Module 3: Page Navigation

Module 4: Page Branding

Module 5: Data List

Module 6: Web Services

Module 7: Event Handlers

Module 8: Content Types and Site Columns

Module 9: Workflow

Module 10: User Management

Module 11: Silverlight

Module 12: Deployment

Building and deploying a simple web part using Visual Studio Extensions for WSS 3.0

0
Filed under Microsoft, SharePoint

This post shows you how to deploy a simple WSS web part using Visual Studio 2008 and Visual Studio Extensions for Windows SharePoint Services.

Install Visual Studio 2008 on your WSS 3.0 Server.

Download and install Windows SharePoint Services 3.0 Tools from Microsoft’s Down Center (http://www.microsoft.com/downloads/.

run Visual Studio.

Choose File, New Project, Select SharePoint and choose Web Part.

This will create a class library and includes references to the sharepoint.dll.

Remove the comments from the sample code.

From Solution Explorer, right-click the project and choose Deploy.

This will create a .wsp deployment package and install it to localhost (Your WSS server. It will also automatically activate the web part.

Now, add the newly created web Part (from Miscellaneous) to a SharePoint page.

ASP.NET: Deploying an AJAX enabled application to SharePoint

0
Filed under ASP.NET, Microsoft, SharePoint

You may develop a web application that uses the ASP.NET AJAX Control Toolkit (http://www.asp.net/ajax/AjaxControlToolkit/Samples), if you plan to deploy this application to a SharePoint Server, you will need to complete the following steps:Copy the AjaxControlToolkit.dll to the BIN folder of the SharePoint server.

  1. Copy the AjaxControlToolkit.dll to the BIN folder of the SharePoint server.
  2. Edit the web.config file as below:
<SafeControls>
      <SafeControl Assembly="System.Web.Extensions, Version=3.5.0.0,     Culture=neutral, PublicKeyToken=31bf3856ad364e35"     Namespace="System.Web.UI" TypeName="*" Safe="True" />
</SafeControls>

<configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
</configSections> 

<pages>
  <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </controls>
</pages>

<assemblies>
       <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>

<httpHandlers>
      <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>

<httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

SharePoint: Redirect to another site/page

0
Filed under Microsoft, SharePoint

Go to the SharePoint page that you require the redirect to take place.

Choose Site Actions, Edit Page.

SharePoint Edit Page

SharePoint Edit Page

Add a new XML Web Part to the page.

Add Web Part

Add Web Part

Choose Edit, Modify Shared Web Part.

Modify Shared Web Part

Modify Shared Web Part

Select the XML Editor Button.

XML Editor

XML Editor

Input the following XML:

<meta http-equiv="refresh" content="0"; url="http://www.google.couk<URL>">

Replace http://www.google.co.uk with the url of the site/page you wish to redirect to.

Choose OK to close the Editor.

Expand Layout and choose Hidden.

Hidden Web Part

Hidden Web Part

Click OK, then Exit Edit Mode.