Monday, August 3, 2009
SharePoint Task List Form View Settings
I was also having same senario to be implemented in our intranet, Some fileds won't need t0 be view New Task entering view, but those fileds need to be in task editing view and so on so on.
In case i found a usefull article which describes how to achieve that what I was looking for....
This is the link...
Regards
Lakmal Kankanamge
Sunday, May 3, 2009
How to Find Start Date and End Date of a Week in given Date
DateTime currentDate = DateTime.NOW;
Here is the code snippet to find the Start Date and Last Date of this week.
DateTime currentDate = DateTime.Now;
int week = myCal.GetWeekOfYear(currentDate , System.Globalization.DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, DayOfWeek.Monday);
DateTime BeginingOfYear = new DateTime(DateTime.Now.Year, 1, 1);
System.Globalization.Calendar D = System.Globalization.CultureInfo.CurrentCulture.Calendar;
DateTime Weeks = D.AddWeeks(BeginingOfYear, Convert.ToInt32(week));
DateTime FirstDayOfWeek = Weeks.Subtract(new TimeSpan((int)Weeks.DayOfWeek, 0, 0, 0));
DateTime LastDayOfWeek = FirstDayOfWeek.AddDays(7);
Here We can Replace the current Date with the Date, Date that you have given.
Regards
Lakmal Kankanamge
How to Upload Files to SharePoint Doc Library...
I found this code snippet from a SharePoint Forum thread, It is about How to upload Files into SharePoint Document Library Using SharePoint API. Credit Should to original developer.
using (SPSite siteCollection = new
SPSite(url))
{
using (SPWeb spWeb = siteCollection.OpenWeb())
{
SPList spList = spWeb.GetList(url);
string fileName = "XXXX";
FileStream fileStream = null;
Byte[] fileContent = null;
try
{
string docPath = XXXX; //physical location of the file
fileStream = File.OpenRead(docPath + fileName);
fileContent = new
byte[Convert.ToInt32(fileStream.Length)];
fileStream.Read(fileContent, 0, Convert.ToInt32(fileStream.Length));
spList.RootFolder.Files.Add(spList.RootFolder.Url + "/" + fileName, fileContent, true);
spList.Update();
}
catch (Exception ex)
{
}
finally
{
if (fileStream != null)
{
fileStream.Close();
}
}
}
Regards
Lakmal Kankanamge.
Friday, April 24, 2009
How to Start SharePoint Development....
The core SharePoint Services platform is comprised of more than 3000 API's. The most fundamental of these are found in the Microsoft.SharePoint namespace. The classes in this namespace will be used in virtually every Web Part and application development effort, so this is a good place to start.
The four key classes you'll need to become familiar with first are SPContext, SPSite, SPWeb, and SPUser. The SPContext class represents the context of an HTTP request in SharePoint Services. The SPSite class represents a collection of sites, including the top-level site and all children sub-sites. The SPWeb class is used to represent a single site in SharePoint. And, the SPUser class is used to represent a single user. Using these classes together lets you access virtually all information about sites and users, both in and out of the current site context.
In most situations, you'll need to know in what site context your code is currently running. To obtain this information, use the following code:
SPWeb web = SPContext.Current.Web;
If you are interested in retrieving the current site collection, use this code:
SPSite siteCollection = SPContext.Current.Site;
And if you need to access a site collection for a different context, you can use the following approaches:
SPSite siteCollection = new SPSite( "http://yourdomain/sites/hr" );
or
SPSite siteCollection = new SPSite( siteGUID );
Many times you'll want to obtain the current user for the current site context. Give this a try:
SPWeb web = SPContext.Current.Web;
SPUser currentUser = web.CurrentUser;
If you want to use some of what we learned above in a custom Web Part development effort, your code may look something like the following:
protected override RenderContents( HtmlTextWriter writer )
{
// Obtain context of current site and user.
SPWeb web = SPContext.Current.Web;
SPUser user = web.CurrentUser;
// Display the current users name.
writer.WriteLine( "Greetings: " + user.Name );
}
Obviously, this is a very basic example, but I hope it gives you a clear idea of how to use the current site context to obtain information about the site and user for which your code is executing.
Regards
Lakmal Kankanamge
Wednesday, April 22, 2009
SharePoint Resourses
http://blog.sharepointhosting.com/Downloads/SharePoint-Tutorials.aspx
http://www.fpweb.net/sharepoint-hosting/free-sharepoint-tutorials.asp
http://www.sharepoint-videos.com/
http://blog.rafelo.com/2008/06/exposing-and-creating-hidden-sharepoint.html
http://blog.rafelo.com/2008/06/exposing-and-creating-hidden-sharepoint.html
http://www.sharepoint-tips.com/
http://sharepointobjectmodel.blogspot.com/
http://blogs.msdn.com/sharepoint/ - Microsoft SharePoint Team Blog
http://nathan.blenke.com/articles/creating_a_sharepoint_2007_theme/
http://msdn.microsoft.com/en-us/office/aa940989.aspx
http://www.worldofasp.net/tut/UpdatPanelError/Handling_and_Customizing_UpdatePanel_Errors_Gracefully_260.aspx
http://blog.visualstudioteamsystem.com/post.aspx?item=23 - SharePoint Development and Programming
http://rshelton.com/Tags/How%20to/default.aspx
http://msdn.microsoft.com/en-us/office/aa940989.aspx - Sharepoint Videos
http://office.microsoft.com/en-us/help/FX100485361033.aspx?pid=CL100605171033 - SharePoint Course with Audio Explanation.
http://www.slideshare.net/Magganpice/introduction-wss-3-and-moss-2007
http://blogs.msdn.com/sridhara/archive/2008/05/24/digging-into-why-sharepoint-navigation-apis-wouldn-t-work-on-sites-using-collaboration-or-publishing-site-definition.aspx - Navigation Programming
http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3 -- Integrate ASP.NET AJAX with SharePoint
http://www.toddbaginski.com/blog/archive/2007/12/26/how-to-programmatically-customize-site-navigation-in-wss-3.aspx - Customize Navigation
http://www.sharepointdevwiki.com/display/public/Where+to+start+with+SharePoint+Development -- Where to start sharepoint development
http://www.sharepointdevwiki.com/display/public/Creating+a+List+programmatically+using+the+object+model -- Sharepoint Code Snippet
http://www.sharepointkings.com/2008/08/create-custom-listviewwebpart.html - Customer List View
http://www.sharepointkings.com/
Web Service Examples
http://blogs.msdn.com/arpans/archive/2007/07/24/sharepoint-web-service-example-grabbing-wiki-content.aspx
http://blogs.msdn.com/ericwhite/archive/2009/01/06/getting-started-with-sharepoint-wss-web-services-using-linq-to-xml.aspx
http://www.csharphelp.com/archives4/archive602.html
http://www.developer.com/tech/article.php/3104621
http://www.sharepointdevwiki.com/display/public/SharePoint+Web+Services
http://www.infoq.com/articles/swanson-moss-web-services
Regards
Lakmal
Sunday, March 22, 2009
ASP.NET Required Field Valuator Causes problems in Tab Container
Normally with ASP.NET Tab Container we manage to keep few Data Forms in several Tab Panels. For example, One Tab Panel has User adding Form and other one has Customer Adding Form.
In Add User View We have Few Required Filed validate controls to validate few fields and in same way Add Customer Form Also having few Required Field Validate Controls to validate some user input fields.
Add User Form and Add Customer View...
The Problem I faced is like, when we submit the Add User form with user information, the Required Field Validate Controls in Add Customer Form are also fired. Then as the result, nothing is happened. Finally I found the solution for this after browsing the internet few minutes.
We need to have value for ValidationGroup Property in the Required Filed Validate Controls and for the same form every Validate Controls should have same value for Validation Group Property. And also make sure to set ValidationGroup property for the button in the form as the same value as the form's Validate Controls.
Then what happens I like, when the button press, it only validates Controls which are in the Same Group as it's ValidationGroup Property.
Cool everything went successfully.
Lakmal Kankanamge.