Monday, October 19, 2009

How To: How to redirect to custom Edit Page in MOSS 2007 ?


Usually, the Edit page of the "Sharepoint List" will be like three columns. First column will be a lable of the field, second column will be the seperator, third column will be the field control like Text box, calender control or people picker, etc... 

Sample Edit Form




Sometimes, you are in a situation to modify the look and feel of "Edit" page of list/document library  like the below image.



This can not be done in MOSS by editing the EditForm.aspx page. Instead, we can create a Blank Webpart page (ex: EditAsset.aspx) and we have to insert our customized Web Part. OK. We have created a page to modify the Content of the List/Document Library. But, How to redirect the users to this page, whenever they are trying to edit the list?

Well. This can be done in 2 ways. 
1. We have to add custom menu item in context menu of the list/document library, wherever we are displaying the content. (This is very difficult. because we have to add javascript in each and every page, if we are going to display the list)

2. Redirecting to our Custom Edit Page from EditForm.aspx page

Second approach is easy one to follow. So, I will tell you how to redirect from EditForm.aspx page.

1. Open SharePoint Designer 2007
2. Open the Website
3. Go to the Document Library/List.
4. Go to "Forms" folder inside the document library.
5. Open "EditForm.aspx"
6. Insert one "Content Editor Web Part"
7. Write the below code inside the Content Editor Web part.

Code:


<![CDATA[<script language="javascript">

var query = window.location.search.substring(1);
var vars = query.split("&");

var2 =vars[0].split("=");

location.href = '/Pages/EditAsset.aspx?EditID=' + var2[1];
</script>]]>


So, The page will be redirected to our custom edit page. 

In the above code, i have splitted the querystring from EditForm.aspx and sending the value to My "EditAsset.aspx" as a querystring parameter. 

See my below image, that will explain how to add the code in the sharepoint designer.



(Click on the image to enlarge)

Thats it...

Thursday, October 15, 2009

Error: A Single Sign-on error has occurred. Please contact an administrator. Details: Could not find domain controller for this domain

Error:
A Single Sign-on error has occurred.  Please contact an administrator.  Details: Could not find domain controller for this domain.

Reason:
You will get this error, when you are trying to configure the SSO (Single Sign-On) in MOSS 2007. The reason is the specified account may not be a member of "Domain Controller" group.

Solution:
Ask your network administrator to add the specified user account into the "Domain Controller" group in the Active Directory. 


Monday, October 5, 2009

Error: System.Data.SqlClient.SqlError: The media family on device 'C\WSS_Content' is incorrectly formed. SQL Server cannot process this media family.

Error: 
System.Data.SqlClient.SqlError: The media family on device 'C\WSS_Content' is incorrectly formed. SQL Server cannot process this media family.

Reason:
Sometimes you will get this kind of error, while you are trying to restore the backup of Sharepoint Content Database in SQL Server 2005. But the back up content may be taken from SQL Server 2008. This is the cause of the issue.

Solution:
Open SQL Server 2008 Management studio and Restore the database.



Thursday, October 1, 2009

Error: No Excel Calculation Services is available in the farm.

Error:

Sometime you will get error like below, while you are loading excel sheet in your SharePoint Excel Web Access web part.

1. No Excel Calculation Services is available in the farm.

(or)

2. There was an error in communicating with Excel Calculation Services http://SenMoss:56737/SharedServices2/ExcelCalculationServer/ExcelService.asmx exception: The request failed with HTTP status 503: Service Unavailable.

(or)

3. Unable to reach Excel Calculation Services http://SenMoss:56737/SharedServices2/ExcelCalculationServer/ExcelService.asmx.

Reason:
Your IIS application pool for Excel Calculation services may not be enabled. 

Solution:

1. Go to IIS (Type "InetMgr" in Command Prompt")
2. Open "ApplicationPools" node 
3. Select "OfficeServerApplicationPool".
4. Right Click on ir and select "Start"


Tuesday, September 29, 2009

Error: Cannot make a cache safe URL for "createsilverlghtobjects.js", file not found

Error:
Cannot make a cache safe URL for "createsilverlghtobjects.js", file not found.

Reason:
You may not copied the "createsilverlghtobjects.js" into "_layouts" folder. You may be modified the "_Layouts" site path to some other location, instead of default location like 
"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS_10002\".

But silverlight application will look into the physical path of "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033" folder.

Answer:
So, put that  "createsilverlghtobjects.js" file or someother required files into "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033" folder. 

Friday, September 25, 2009

How To: Integrating Silverlight User Control with SharePoint WebPart (MOSS 2007)

Silverlight with MOSS 2007
Developing a webpart may be very simple. Likewise, Developing a Silverlight application also will be very simple. But, If you are going to integrate both areas, that will be difficult little. Here, I am going to tell you that what are necessary steps that needs to be followed, while integrating the MOSS & SILVERLIGHT.

OK. See the steps below. (I assumes that you are familier with creating SharePoint webpart & creating sivlerlight Web applications.)

1. Whenever you are creating Silverlight applications, you can see a "Silverlight.js" file in your "Web" folder. For example, if your application name is "HelloWorld", your visual studio will create another folder with the name of "HelloWorld_web" or "HelloWorldWeb". Within this folder, you can see a file "SilverLight.js". Copy this file and paste it into "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033". (Note: you should paste that file, only into this folder. Else, you will get an error".

2.  Create an Silverlight application and generate a XAP file.

3. Go to "c:\Inetpub\wwwroot\wss\VirtualDirectories\7070" and create a folder named "ClientBin" and give permission to Read & Write (for everyone). 

4. Go to IIS 

5. Go to Your SharePoint portal and make the "ClientBin" folder as a Virtual Directory.

6. Copy the Silverlight Application DLL & XAP file into this ClientBin folder.

7. Modify the Web.Config file to integrate the Silverlight. You can download a sample web.config file in the "download" section of http://www.codeplex.com/SL4SP

8. Create a Webpart. You can use WSPBuilder to create a Webpart. You can download a WSPBuilder from http://www.codeplex.com/wspbuilder

9. Add 2 references in WSP Project (System.Web.Extensions & System.Web.Silverlight)

10. In the WebpartCode, you must inherit the below 2 namespaces.
a. using System.Web.UI.SilverlightControls;
b. using System.Web.UI.WebControls;

11. Write a code to call the XAP file within the "CreateChildControls" method like. 
Silverlight sl = new Silverlight(); 
sl.ID = "MYSL"; 
sl.Source = "/ClientBin/SenSLMOSS.xap"; 
sl.Height = Unit.Pixel(420); 
sl.Width = Unit.Pixel(420); 
this.Controls.Add(sl);

12. "ScriptManager" code also should be placed inside the WebPart code. See the sample code below and this code should be inside the "OnLoad" method, like,

  protected override void OnLoad(EventArgs e) 
{
 if (!_error) 
try
 { 
base.OnLoad(e); 
ScriptManager sm = ScriptManager.GetCurrent(this.Page); 
if (sm == null) 
sm = new ScriptManager(); 
Controls.AddAt(0, sm); 
this.EnsureChildControls(); 
}
 catch (Exception ex) 
HandleException(ex); 
}


13.  Add & Deploy the WSP Webpart using stsadm command. 
(stsam -o addsolution -filename "C:\SLMOSSWebPart.wsp")

14. Create a "WebPart page and insert this webpart into that newly created page.

15. You will see an amazing SilverLight Page.

Thats  it...

Error: Could not complete the operation due to error 80000012

Reason: 

While integrating the Silverlight XAP files into MOSS 2007 webpart, you will get this error. Because, your given path may not be in correct format.


Answer:
You may have mentioned the XAP file path like "\ClientBin\HelloWorld.xap".
Instead, use like "/ClientBin/HelloWorld.xap"