About Me

My photo
a Dynamic and Energetic guy.....

Monday, September 7, 2009

Sharepoint Webpart Concepts

In order to create WSS-style Web Parts, you must have a dependency on the Microsoft.SharePoint.dll and you must inherit from the WebPart base class in the Microsoft.SharePoint.WebPartPages namespace.

In order to create ASP.NET-style Web Parts, you have a dependency on System.Web.dll and inherit from a base class named WebPart in the System.Web.UI.WebControls.WebParts namespace.

When creating WSS 3.0 Web Part pages, you should use the WebPartZone control defined in the Microsoft.SharePoint.WebPartPages namespace. You do not want to use the WebPartZone control contained within ASP.NET 2.0.



Different controls contained in a WSS-style Web Part page


The preferred way to create Web Parts for WSS 3.0 sites is to create the ASP.NET style WebParts. As discussed before, this means inheriting from the WebPart base class in the System.Web.UI.WebControls.WebParts namespace and overriding the RenderContents method.

Sunday, September 6, 2009

Sharepoint Standard Versus Enterprise Edition

MOSS 2007 comes in both Standard and Enterprise Editions. Based on the needs we can choose to implement Standard Edition and upgrade to Enterprise Edition at a later time, or
immediately implement Enterprise Edition with all of its additional features.
Although there are many small differences between the two editions, the following are
the significant features included in Enterprise Edition but not in Standard Edition:

Excel Services
This feature provides access to Excel spreadsheets through a web browser and
offloads the calculations to the server. It makes only specific areas of the spreadsheet
visible to users, and ensures that there is “one version of the truth,” since
only specified users can modify the underlying data.

Report Center
This is a site provided out of the box that has been designed to simplify the management
of reports and data connections.

Business Data Catalog
This feature is a simplified way to bring data from external sources into Share-
Point without costly custom development. With it, users do not need to access
multiple systems to view the data they need—it is all available from one common
interface provided by MOSS.

Business Data Search
This feature allows users to search data that has been stored in separate systems
exposed through MOSS (such as those connected via the Business Data Catalog).

Forms Services
You can create forms within Microsoft Office InfoPath 2007 and publish them to
SharePoint using Forms Services, allowing users without the InfoPath client to
complete forms entirely through their web browsers.

Sunday, August 30, 2009

Usefull code samples in C#

// Getting the pressed key
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
// Code for the "Enter" key
}


//Check Other Name that has Mr. & "Spaces"
public static bool IsOtherName(string strOtherName)
{
Regex Pattern = new Regex("[^a-zA-Z\\.\\ ?]");
return !Pattern.IsMatch(strOtherName);
}

// String format for "Money"
String.Format("{0:0,0.00}", objRenewal.policy.dblPremium.ToString())

Tuesday, July 28, 2009

Sharepoint 2010 Overview

It's time to have a look new features that we want in sharepoint !!!

  1. Look & Feel (Ribbon Control)
  2. Multi document Checkout + avoid from post backs
  3. Nice pop-up windows than response.redirects J
  4. Direct uploading & showing images from your computer to sharepoint
  5. SilverLight webpart
  6. Nice themes like "PowePoint Theme"
  7. Visio services running with sharepoint services (Visio is not necessary)
  8. Fully rich Sharepoint Designer
  9. Entities to connect SQL,LOB with Edit/Delete functions (OOB)
  10. Direct connect to the office tools like Office 2010 with a click J

Change the data in a Infopath form library programatically

First we have to take care few things
(1) We should allow unsafe upates = true
(2) We should check out the file




(3) We cant use our item update event inside "SPSecurity.RunWithElevatedPrivileges(delegate.."
Code is simple

SPSite objSite = new SPSite("http://sharepointsvr:123/");
SPWeb objWeb = objSite.RootWeb;
SPFolder oFolder = objWeb.GetFolder("Participant");
SPFileCollection collFiles = oFolder.Files;
objWeb.AllowUnsafeUpdates = true;

foreach (SPFile oFile in collFiles.Folder.Files)
{
SPListItem oListItem = oFile.Item;
oListItem.File.CheckOut();
oListItem["ProgramaticField"] = "Chanaka has done it";
oListItem.SystemUpdate();
oListItem.File.CheckIn("chana did");
}

Thursday, July 23, 2009

Sharepoint hints

Web Services that we are getting
http://sharepointsvr:15613/_vti_bin/lists.asmx


How I enable Anonymous+Access
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExfqTp8opjEIK37d5Ak4m23971jeqCoa4-EHhSnu0oqx4lViqvpxT63woZntJ6w5PBKMds_vztzOULvs4wjiZdLxi6CEtipwWKv9thleI2Y4oy5wefeeXxUcVo1W1iK4IYNsUOujojU0/s1600-h/Anonymous+Access.JPG

Get the response of web request programatically

StreamReader responseReader = null;
HttpWebRequest httpRequest = null;
httpRequest = (HttpWebRequest)WebRequest.Create("http://172.21.0.60:8034/");
httpRequest.Method = "GET"; // User get data

HttpWebResponse webResponse = null;
webResponse = (HttpWebResponse)httpRequest.GetResponse();
Encoding enc = Encoding.Default;
responseReader = new StreamReader(webResponse.GetResponseStream(), enc);
String temp = responseReader.ReadToEnd();

Wednesday, July 22, 2009

Infopath data retrieve with Sharepoint

SPSite objSite = new SPSite("http://sharepointsvr:123/");
SPWeb objWeb = objSite.RootWeb;
SPList objList = objWeb.Lists["Participant"];
SPQuery objQuery = new SPQuery ();
SPListItemCollection objCollection = objList.GetItems(objQuery);
SPListItem objItem = objCollection[0];
SPFile objFile = objItem.File;
byte[] xmlFormData = objFile.OpenBinary();
XPathDocument ipForm = null;
using (MemoryStream ms = new MemoryStream(xmlFormData))
{
ipForm = new XPathDocument(ms);
ms.Close();
}
XPathNavigator ipFormNav = ipForm.CreateNavigator();
XPathNavigator nodeNav = ipFormNav.SelectSingleNode("/my:myFields/my:fldFamilyName", GetFormNSM(ipForm));
string strValue = nodeNav.InnerXml;
Response.Write(strValue);


//XML Namespace Creator

private XmlNamespaceManager GetFormNSM(XPathDocument ipForm)
{
const string strMYNamespacePrefix = "my";
const string strMYNamespaceURI = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-06-25T10:50:10";

const string strDIRNamespacePrefix = "d";
const string strDICNamespaceURI = "http://schemas.microsoft.com/sharepoint/soap/directory/";


XPathNavigator formAccess = ipForm.CreateNavigator();
XmlNamespaceManager namespaceMngr = new XmlNamespaceManager(formAccess.NameTable);
namespaceMngr.AddNamespace(strMYNamespacePrefix, strMYNamespaceURI);
namespaceMngr.AddNamespace(strDIRNamespacePrefix, strDICNamespaceURI);

return namespaceMngr;
}

Monday, July 13, 2009

RunWithElevatedPrivileges in sharepoint


When we try to get data from a document library that is not assigned for current user, we are getting this error.

Solution is:::::

SPSecurity.RunWithElevatedPrivileges(delegate()
{
…
//any code that we have to use
});


Sometimes even we add this delegate still it's not working.
That's because the object we are using made without elevated privileges.
(Ex:- We are creating SPWeb under the delegate, but the SPSite(parent object) object is outside the delegate, then we won't get chance to access data)

My Masters