Thursday, March 4, 2010

Installating SharePoint 2010 Beta in Windows 7

When SharePoint 2010 Beta was released for installation, I was very excited. And then when it was clearly mentioned that it can be installed on Windows 7, then I was more excited. It was because I faced lot of trouble installing SharePoint 2007 on Windows Vista. However, later I found customized solution/installer from Bamboo solutions that allows the installation on to Windows Vista. Pretty good work by Banboo Solutions.

There are lots of MSDN articles available that will instruct you (step by step) to install SharePoint 2010 (Foundation and/or Server) on Windows 7 (Home Premium/Professional/Ultimate). The one MSDN article that I referred was http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx. Everything is good here.

Home Laptop: Intel Core 2 Duo, Dell XPS with 4GB RAM (Maximum).

SharePoint 2010 Foundation: Installation goes smoothly. With this installation I thought that SharePoint installation is piece of cake and I can install SharePoint 2010 Server on office machine.

Home machine is WorkGroup machine and Office laptop is actually domain connected machine. This is important point here.

Office Laptop: Dell Latitude D620 with 4GB Of maximum RAM.

Downloaded SharePoint 2010 Server software and followed the instructions given in the MSDN web site. Prior to this installation, I did install SQL Server 2008 Enterprise Edition (64-bit). SharePoint 2010 Server installation was smooth. The challenge started when tried to do configuration. Configuration was failing at step 2 with one reason on other. I was freaked out and was thinking the root cause of the failure. I tried so many times, but failed at step 2 of 10 all the time. hmm!!!

Then I recalled by SharePoint 2007 configuration pre-requisite, it says that do the installation with a domain service account. Now I am using office laptop which is not actually connected to domain, however, I am trying to install the application with domain account. What I thought was that if I have Local machine service account which is not actually domain service account, it will definitely work. WIth this thought, I un-installed SharePoint 2010 Server first using my domain account.

Created a local account and make it local admin to the box. Logged off from domain account and then log back again using local service account.

Started SharePoint 2010 Server installation, completed successfully.

Started SharePoint Configuration using configuration wizard. Chose 'Standalone' installation (with my fingers crossed). Step 2 configuration going on... going on... and after 5 minutes or so, step 2 installation completed and it continued till step 8 of 10 without any problems. I was sure that now installation will complete without any problem, however, my assumption was wrong and it failed at step 8. Never mind. I thought of checking the SharePoint Configuration and Content databases if created successfully, and it did.

Started SharePoint 2010 Central Administration, and bingo ... you will see the central administration is running without any problem. Default website is not accessible because step 8 was failed. So you need to create the default website by yourself. I did create the default website that runs on http://machineName/.

Couple of Important Points here:

1. Create local machine service account with 'never expired' password policy.

2. Add this local machine service account in local administrator group.

3. Logon to machine using this service account.

4. Install SharePoint 2010 (Server/Foundation) and complete the configuration. Make sure to use 'Standalone' option. I haven't tried another option.

5. If installation continues and pass step 7 of 10, no worries. Step 8 till 10 is basically for (I guess) to create default site and related configurations.

6. Installation using domain account doesnt work unless you are actually connected to domain.

Good Luck and Enjoy SharePoint 2010!!!

Monday, February 8, 2010

Disable ASP.NET Button while processing in Background

Today, I was stuck in a simple scenario, where I wanted to restrict end user to click a button only once. Looked simple, and while starting implementation, doesn't found it simple enough.

I asked my friends and different people gave me different opinions and options. I was looking for the good option without putting extra code.

So here is the Default2.aspx code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Background Processing while disabling main button</title>
<script type="text/javascript" language="javascript">
function disableBtn(btnID, newText) {

var btn = document.getElementById(btnID);
setTimeout("setImage('"+btnID+"')", 10);
btn.disabled = true;
btn.value = newText;
}
//using absolute url for image to avoid complication
function setImage(btnID) {
var btn = document.getElementById(btnID);
btn.style.background = 'url(http://images.ysatech.com/ajax-loader.gif)';
}
</script>
</head>

<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnOne" runat="server" Text="Process" OnClientClick="disableBtn(this.id, 'Processing...')"
UseSubmitBehavior="false" OnClick="btnOne_Click"/>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>

And then Default2.aspx.cs code here:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnOne_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
Label1.Text = DateTime.Now.ToLongDateString();
}
}

Special Thanks to Bryian.

Friday, June 5, 2009

Display XML string on Browser

Initially I thought that it is very simple task. I was surprised myself that it is not so simple as I thought.

My requirement: XMLs are stored in SQL Server 2005 database in XML data type field. On web page, I wanted to display a hyperlink and when user click to this hyperlink, then the xml should display for the selected ID.

My Solution:
Created a sample web application, here is the code snippet of Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ShowXmlOnPage._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd >">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></a>;
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>" ><head runat="server"> <title>Untitled Page</title></head><body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>

And then subsequent code behind page(Default.aspx.cs) is:


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Xml.Xsl;

namespace ShowXmlOnPage
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(MapPath("Vendor.xml"));
Response.Write(LoadXmldocument(doc));
}
private string LoadXmldocument(XmlDocument xmlDocument)
{
System.IO.Stream s = System.IO.File.OpenRead(MapPath("defaultss.xsl"));
System.Xml.XmlReader reader = System.Xml.XmlReader.Create(s);
XslCompiledTransform transform = new XslCompiledTransform(true);
transform.Load(reader);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
XmlWriter writer = XmlWriter.Create(sb);
transform.Transform(xmlDocument, writer);
return sb.ToString();
}
}
}

The .NET Solution file require a couple of other files too.
1. Vendor.xml file - Here is the XML file:
<?xml version="1.0" encoding="utf-16" ?><Response> <Success> <Operation>PlaceOrderCredit,PlaceSalesOrderPOs,Payment</Operation> <SORefNumber /> <PONumber /> <PONumber /> <SalesReturnRefNumber /> <CreditRefNumber /> <RMARefNumber /> <PaymentRefNumber /> </Success> <Failure> <Operation>PlaceOrderCredit,PlaceSalesOrderPOs,Payment</Operation> <SORefNumber /> <PONumber /> <PONumber /> <SalesReturnRefNumber /> <CreditRefNumber /> <RMARefNumber /> <PaymentRefNumber /> <ErrorMessage /> </Failure></Response>

2. defaultss.xsl - This file I downloaded from "http://blorgh.files.wordpress.com/2006/10/defaultss.txt". Thanks to the author who has modified this xsl file. Save the file as "defaultss.xsl" - that is what I referenced in the code.

And that's it. This is the sample application where Vendor.xml is physically present in the solution folder. It is required to have defaultss.xsl present in the web folder too.

Happy Coding!!!

Wednesday, May 20, 2009

Loading excel data column (alpha-numeric) using OLE DB adapter

Problem: One of the excel data column has alpha-numeric data stored. While loading the data using Ole DB adapter, adapter preset the data type to numeric and subsequently doesn't read the alpha numeric content.

Solution: While defining the connection string, define it as:
string connectionString = "Provider=Microsoft.Jet.OleDb.4.0;Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';";
connectionString += "data source='C:\Temp\FileTobeProcessed.xls';";

we generally define the extended properties = 'Excel 8.0;' only and forget to add, if excel file has header, or treat the column data type as alpha-numeric (add IMEX=1 in extended properties).

It helped me a lot of places, mostly, when I used Dynamics GP eConnect to transfer Items from One bin location to another, and item number data was alpha-numeric.

Tuesday, March 3, 2009

MATSHITA DVD +- RW UJ 857G Driver Problem/Solution

I have DELL XPS 1330 with MATSHITA DVD UJ 857G DVD Drive. Because of nVidia problems, the mother board is replaced three times (thanks GOD that I took 3 years warranty on it), so I didnt pay a single penny so far on repairs.
Now I formatted it with Vista Ultimate 64bit and later I found that Vista is not detecting drivers for DVD.
I searched a lot but didnt find any suitable driver.
In device manager for the drive, I was getting error 32, and googled it based on the error description,and then I found the following posting:
http://www.pchell.com/hardware/cd_drive_error_code_39.shtml

It talks about error 39, still I did the same what the post says... and deleted entry LowerFilters - PxHlpa64. Restarted the computer, and noticed that drive is working just fine.

Tuesday, January 6, 2009

Read QueryString Parameter and use in CAML to display specific blog category Posts

Well, SharePoint is full of challenges, and one day before I was stuck on this problem. I modified Blog Category page, and hence the page became customized. Now when I click a specific blog category, the page was displaying all the posts having no category defined. I was confused what is happening. Apparently I looked the CAML Query in 'SelectCommand' attribute and found the CAML as:
<View><Query><OrderBy><FieldRef Name="PublishedDate" Ascending="FALSE"/><FieldRef Name="ID" Ascending="FALSE"/></OrderBy><Where><Eq><FieldRef Name="PostCategory"/><Value Type=""><GetVar Scope="Request" Name="Name"/></Value></Eq></Where></Query></View>"

Looked Ok to me! What is wrong in there. Noticed that how <GetVar> is working here. I thought of modifying the CAML query, but thought to investigate further using SharePoint Designer. BTW, here I am modifying WebPartPages:DataFormWebPart that has my custom formatting.
  1. Now clicked this DataFormWebPart and a left arrow appears on the right of the same window, click it.
  2. The window is titled as 'Common Data View Tasks'.
  3. Click the top option - Filter.
  4. When you click this 'Filter' option, 'Filter Criteria' window will open.
  5. Click 'Click here to add a new clause...'.
  6. Select the Field Name - In my case it was 'Category'.
  7. Select Comparison value as 'Equals'
  8. Select Value field and drop down option, click the last option...Create a new parameter. As soon as you click this new parameter option from drop down list, a new window will open titled as 'Data View Properties'.
  9. Under Parameters, Type 'CategoryName' for 'Param1'. You can name anything here.
  10. For Source Column, on the right side, select 'Query String' from the 'Parameter Source' drop down combo box.
  11. As soon as you select 'Query String' from drop down, two new text boxes will appear. One is to define the query string variable name. Category page, by default, has 'Name' as Query String value. So Type 'Name' in Query String Variable Text Box.
  12. Leave 'Default Value' text box empty.
  13. Click Ok to close 'Data View Properties' window.
  14. Click Ok to close 'Filter Criteria' window.

You are done here.

And finally when you look back your CAML query, it will look like the following:

<View><Query><OrderBy><FieldRef Name="PublishedDate" Ascending="FALSE"/><FieldRef Name="ID" Ascending="FALSE"/></OrderBy><Where><Eq><FieldRef Name="PostCategory"/><Value Type="Text">{CategoryName}</Value></Eq></Where></Query></View>

And when I ran my category page again for a specific category, filtering was happening correctly.

I am relieved!!

References that I used:

http://msdn.microsoft.com/en-us/library/aa218649.aspx - This I looked to understand the parameter binding relationship and from here I got the clue to look for 'Query String' option as one of the ParameterBindings Name is 'filterParam'. It is interesting article though.

Tuesday, November 4, 2008

Calendar: New Event - Hide 'Workspace' from NewForm or EditForm page

Somebody asked me about hiding a field called 'Workspace' from Calendar: New Event or Edit existing event.
I was wondering that there should be some decent way to hide any field available on 'New' or 'Edit' page.
I googled around, and I found couple of responses, forexample,
1. Modifying the NewForm.aspx page in SharePoint Designer 2007, hiding existing List Form Web Part, and then adding Custom List Form. Then delete the Workspace row from the form.

Let me talk about the dis-advantages of this option:
a. Attach File will NOT work. You need to investigate further to make it work. Still painful process.
b. Try to create a 'Recurring' event, it will not work as expected.

Considering these advantages, I thought that this is very tedious process, and one has to make the changes to all calendar lists. And then this change is required to be done on NewForm.aspx and EditForm.aspx. How about that? So it is really very painful process.

2. Another option is again, modifying the NewForm.aspx or EditForm.aspx, and add following script (However, it didnt work for me though), but it is worth adding it here, just in case, if people are trying to solve the problemin this manner.
<script language='javascript' type='text/javascript' >
var toolbar = document.getElementByName("<name attribute value>"); toolbar.parentNode.parentNode.parentNode.style.display = 'none'; toolbar.parentNode.parentNode.style.display = 'none';
<script>

This can be added in asp:content ContentPlaceHolderId="PlaceHolderTitleAreaClass".
Once again as I said that it didnt work for me, but it can be done this way too.

3. Recommended way. First thing is that it is a feature, and can be found (12 Hive folder) at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Template\Features\EventsList. Yes, it is event list feature. Now the modifications are required in schema.xml that can be found under Events folder (folder location, once again, is ..\12\TEMPLATE\FEATURES\EventsList\Events). This file can be modified in notepad.exe.
While looking into the Calendar List Settings in Internet Explorer, I noticed that this field 'Workspace' is of type 'Cross Project Link'. This is important to remember, and search 'CrossProjectLink' in schema.xml file. I noticed there is only one instance of it.
Secondly, the field is SharePoint field so looked for the corresponding class which is SPField. I looked into SPField Class Members on
MSDN and found a couple of interesting properties (and used two of them), for example, ShowInDisplayForm, ShowInEditForm, ShowInListSettings, ShowInNewForm, ShowInVersionHistory, ShowInViewForms. I was interested in ShowInEditForm and ShowInNewForm properties only. So in schema.xml file, for Field of Type="CrossProjectLink", added these two properties as attributes, and set the value="FALSE".
IMPORTANT: attribute value should be set as ShowInNewForm="FALSE" (case sensitive). If you set the value as ShowInNewForm="false", it will not work, so be careful here.
My final <Field> is looked like:
<Field ID="{08fc65f9-48eb-4e99-bd61-5946c439e691}" Type="CrossProjectLink" Name="WorkspaceLink" Format="EventList" DisplayName="$Resources:core,Workspace;" DisplayImage="mtgicon.gif" HeaderImage="mtgicnhd.gif" ClassInfo="Icon" Title="$Resources:core,Meeting_Workspace;" Filterable="TRUE" Sealed="TRUE" SourceID="
http://schemas.microsoft.com/sharepoint/v3" StaticName="WorkspaceLink" ShowInEditForm="FALSE" ShowInNewForm="FALSE">
As mentioned, I added only two attributes.
Save the schema.xml file.

Now the task is to publish the feature with changes. And since the feature is already installed and activated, so it is mandatory to de-activate it and then un-install it.

To smoothen the process I wrote two batch files one each for de-activate, un-install and install, activate:
script for uninstallfeature.bat

path="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
cd\
cd "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
stsadm.exe -o deactivatefeature -filename EventsList\Feature.xml -url
http://moss2007:8551/sites/Demo1
stsadm.exe -o uninstallfeature -filename EventsList\Feature.xml -force
cd\

It is straight forward to understand, however, if you want instructions for the same, can send me request.

script for installfeature.bat

path="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
cd\
cd "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN"
stsadm.exe -o installfeature -filename EventsList\Feature.xml
stsadm.exe -o activatefeature -filename EventsList\Feature.xml -url
http://moss2007:8551/sites/demo1
cd\

URL is required to install the feature, in this script, I am deploying the feature for a specific website.
Dont forget to do IISRESET

I am done, and when I tried to create or edit a calendar event, I don't see 'Workspace' option in there. I double checked that attach file is working, and I am able to create a 'Recurring' event too.
It is really very useful tip for me, so thought let me add it here for future reference too.


Update as on 01/13/2009:
1. The approach described here is applicable for a website. For example, if there are different calendars for different locations or divisions for an organization, then this approach can be used to hide a field in all calendars in that website. However, if the requirement is to show/hide 'Workspace' field for a specific list, there is a tool available in http://www.codeplex.com/spm [Thanks for Boris].