Thursday, September 18, 2008

Dates and FullTextSqlQuery

When comparing dates in a FullTextSqlQuery remember the date literal must be surrounded by single quotes and formatted in YYYY-MM-DD format.

Example: 

SELECT Title,FileExtension,ContentType,Path FROM SCOPE() WHERE  owsStartDate > '2003-12-01'

Trying to use an SPWeb object that has been closed or disposed and is no longer valid

This is one is an olddie but it's never too much, when using SPWeb and SPSite, you should remember the Context, so when doing

using (SPWeb web = SPContext.Current.Web)
{
...
}

You will get a nice "Trying to use an SPWeb object that has been closed or disposed and is no longer valid" because you are disposing an object you really didnt create.

Best practices here.

An unexpected error has occurred

I was tired of looking into my mail for this, so i guess that putting in my blog was a easy way to get this info... How to show debug messagens in MOSS. Basically if have to change the web.config of the Web Application in question:

1.     Change CallStack="false" to   CallStack="true"

2.     Change customerrors mode="On"  to   customerrors mode="Off" 

3.     Change compilation batch="false" debug="false"  to   compilation batch="false" debug="true"

Full Articles here, and here.

Tuesday, September 2, 2008

Setting Current Navigation programatically

In the MOSS UI you can set Current Navigation to any of these options:

  • Display the same navigation items as the parent site
  • Display the current site, the navigation items below the current site, and the current site's siblings
  • Display only the navigation items below the current site
But if you wantto do it programatically how can you?

The default is "Display the current site, the navigation items below the current site, and the current site's siblings" so you dont need to care, when adding a web.

Hope this helps for other options, and you dont need to loose time looking and testing.

//Sets Current Navigation to Display the same navigation items as the parent site
pubWeb.InheritCurrentNavigation = true;
pubWeb.NavigationShowSiblings = false;
pubWeb.Update();

//Sets Current Navigation to Display only the navigation items below the current site
pubWeb.NavigationShowSiblings = false;
pubWeb.Update();
}