Friday, June 24, 2011

Passed the examination 70-573: Microsoft SharePoint 2010, Application Development

I've decided to attend the examination 70-573 because I am working as Developer of SharePoint 2010.
It's not difficult for me because I had attended the Online Course:

and now it helps me a lot in my work, i feel better after finished learning the course and passed the examination. I will return to my blog in short day and continue sharing my knowledge about SharePoint 2007/2010.

Thanks for my co-worker helping.

Tuesday, June 21, 2011

Passed the examination 70-576: Designing and Developing Microsoft SharePoint 2010 Applications

I'm very happy to notice that I just passed the examination of 70-576.

A lot of skills need to be improved if you learn onlin at:

http://www.microsoft.com/learning/en/us/exam.aspx?id=70-576

Of course, that's very good document and orient the right way to pass the examination. After finish the online course you will learn the strongly knowledge to work with SharePoint 2010 with Design and Develop software based on SharePoint 2010.

Thanks again.

Thursday, May 12, 2011

What about the issue of Calendar in SharePoint 2007 show wrong datetime.

I decided to post this issue because I did not find out any wrong in my system, and if it is a WAD or Bug, please confirm this topic is correct and I will send this link to my customer.

Problem:

Install SharePoint 2007 with the default settings for everything. Create a celendar list and then create a column named "My Date Time" or something you want with DateTime type and show both Date and Time.

Create an item in Calendar with All Day Event checked, type a date into "My Date Time"

After save, everything is fine. Please see the picture in view form.

Title, AlldayEvent, My Test Datetime show correctly, data kept. But what is happening when I edit this item?


"My Test Datetime" was wrong, the date is minus 1 day and if I save this item, the data will store this date.

There is very strange that it will not change for the next editing. And this issue does not happen in SharePoint 2010

Tuesday, May 10, 2011

How to format datetime in SharePoint XSLT

In SharePoint (both of 2007 and 2010), Microsoft has implemented  XSLT 1.0 into CQWP (Content Query WebPart) and parse xsl file.

You can find out these file at 14\TEMPLATE\LAYOUTS\XSL, you will see some xsl files such as main.xsl, thread.xsl,... For now, you change reference version of xslt for these files, you will get an error because CQWP only understand the structure of XSLT 1.0. So, there are a lot of limitation to work on DateTime, String,...and other functionings of XSLT 2.0.

However, in SharePoint you can use an alias to get somes already formatted by using ddwrt namespance. Detail for more

It's very easy to use:

<xsl:value-of select="ddwrt:FormatDateTime('2010-may-25', 'G', 1033)"/>


First argument: Date original value
Second argument: Formatted expression, this argument has supported flag/string such as "d" (or 1) for date only as result as "M/d/yyyy"...
Third argument: regional setting. But no support for User Regional Setting


Thanks/

Wednesday, February 23, 2011

how to indicate the type of list definition?

I am working on list definition with the type id is 10001, my list is based on Calendar list.

But how can i indicate my list def is Events List or not?

Thanks for you helping!

Friday, February 18, 2011

Support discussion board list definition in VS2010 template

Visual Studio 2010 had supported List Definition  template to create the project automatically with fully the schema and define the structure of list. Unfonately, it has not supported for Dicussion Board list.

But you can download another template to upgrade your existed template and can use dicussion board list.

Download here

To use this package, please following this instruction:
  1.  Extract this pakage then copy all folders & files into: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\CSharp\SharePoint\SharePoint14\1033\SharePoint14ListDefinition.zip
  2.  Copy this compressed file into: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\SharePoint\SharePoint14\1033
  3.  Please overwrite all files and folders as if request.
Good luck!



Monday, February 14, 2011

"Access denied. Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

Contribute account can access and some actions on the page. I created a new page with inheritance from the default.master of SharePoint 2010.

I tested on SharePoint 2007 and as a result it works smoothly. But in SharePoint 2010, I got an error:

"Access denied. Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

The trace log:



It took me some hours to find out the problem, event thought I run the debugging line by line but it thows the exception before reach the CreateChildControl method. I guest it happens from ASPX or MasterPage.

Here is the problem:


 Some resources of this MasterPage can not be accessed by Contributor account, so just remove them out. Hope this help you fix your issue.

Sunday, February 13, 2011

"Access denied" when using contributor account to access to content-type

When I was using the contributor account to check the content-type folder is "message" or "Dicussion", I got an error: "Access denied!"

My code:

if (ctype.ResourceFolder.Name == "Message")
{
     //do something
}

But nothing happened with owner account.

Yes, because contributor account can not access to ResourceFolder properties of content-type. ResourceFolder was inherited from SPFolder and execute the method FolderEnsure. You know to give the access to folder ensure the account must be set the properties currentWeb.AllowUnsafeUpdates = true; and the default for member account does not have permission to run that update.

You can change the code to look like this:

if (ctype.Id == SPBuiltInContentTypeId.Message)
{
    //do something
}

The result is nearly the same.

Monday, January 24, 2011

How to get all items of Discussion Board list using Web Service.

Hello everybody,
I am working on Discussion Board list using Web Service. I am so supprised that the DB list is not the same as another list in SharePoint. The first sign of my mind is Calendar List Item, SharePoint stores the StartDate & EndDate with a different ways. To get the correctly data, we must understand clearly about architecture of Calendar list.

For now, the problem about Calendar was solved and faced to another problem. Discussion Board list has 2 item types: Dicussion (threads) and Message (replies). When you get all items by normaly, you only get the discussion items, take a look at code:


            XmlDocument document = new XmlDocument();
            XmlNode query = document.CreateNode(XmlNodeType.Element, "Query", "");
            
            XmlNode viewFields = document.CreateNode(XmlNodeType.Element, "ViewFields", "");


            XmlNode queryOptions = document.CreateNode(XmlNodeType.Element, "QueryOptions", "");
            queryOptions.InnerXml = "<ViewAttributes Scope='RecursiveAll'/>";


            Lists lists = new Lists(URL_SERVER);
            lists.Credentials = CredentialCache.DefaultCredentials;
            
            XmlNode node4 = lists.GetListItems(sourceList, "", query, viewFields, "", queryOptions);


Okey, even thought Scope attribute is set to "RecursiveAll", and SharePoint 2007 works fine. All items including reply items are list. But it does not work in SharePoint 2010, so it is not actually difficult to fix for SharePoint 2010. Just update your query CALM like the code below:


query.InnerXml = @"<Query>
                                <Where>
                                    <Geq>
                                        <FieldRef Name=""DiscussionLastUpdated"" />
                                        <Value Type=""DateTime"">1900-01-01T00:00:00Z</Value>
                                    </Geq>
                                </Where>
                               </Query>";
Yes, that's it.

Sunday, January 23, 2011

Show friendly error in SharePoint

Sometime, i dont know why my webpart (or site/page) happens error, event thought i turned off the CustomError tag in Web.Config

<CustomError mode="Off"/>

The default vallue of Mode is "ON", that means, SharePoint will show the error page liek this:

We've never known what about this error and also in the code there are any functions/methods give this issue. So, to let SharePoint show friendly the error and the stack trace of this error, we must change some values/attribute of tag in web.config.

1) Set Mode of <customerror> is Off

<CustomError mode="Off"/>

2) Find the tag <combilation> and change the value of debug is True

<compilation batch="false" debug="true">

3) In <SharePoint> tag, change the attributes of <SafeMode> to be:

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="true">


Remember that doing reset IIS before press F5.


Now you can see your error as details and it's very easy to fix.