[Bug – Visual Studio] Crashing when using big CSS

 

Big css crashing in Visual studio is a known issue with Visual Studio 2011 :

Solution :

  1. Copy the Css on the website : http://www.codebeautifier.com/
  2. Check the checkbox : Preserve CSS
  3. Check the checkbox : Standard compression
  4. Paste the CSS in Visual Studio css file, and it should work (with Notepad, not with visual Studio
Advertisements

[SharePoint 2010 – Error fixing] Content By Query WebPart, display items links with wrong URL

image
You are programmatically creating a ContentQueryWebPart and when you test the solution, you try to click on an item link and you get a :
“404 NOT FOUND” page error

The error :

The Content By Query Webpart displays items url as :
http://jeff/sites/test/News/Lists/Posts/1_.000 or
http://jeff/sites/test/News/Lists/Posts/2_.000

 

Solution :

When you programmatically create the CQWP, you need to set the attribute UseCopyUtil to true.
wpCqwp.UseCopyUtil = true;
After, the item url should works and will look like :
http://jeff/sites/dzdza/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=2&ListId=0b3c3cfc-5724-48e6-85ed-4943eae4f3b9&WebId=954e1a32-c41d-46f1-94b8-615ffd01156d&SiteId=edf289e7-9e97-4429-a9cf-e7d4af9636f2&Source=http%3A%2F%2Fjeff%2Fsites%2Fdzdza%2FSitePages%2FHome%2Easpx

 

Explanation :

By default, when you create a CQWP by the interface, SharePoint set the property UseCopyUtil to true.
Programmatically it’s set to false (i saw it by exporting the webpart, which gave me a .webpart file , and i compared it to a content query webpart created by interface).
Msdn explains, about that property that :
“Objects that are not streamed, such as announcements or calendar events, do not have an associated URL. When you set this property to true, objects that are not streamed have an associated URL that points to the View property of the item. “ Msdn
 
Voila !

[SharePoint 2010 – Error Fixing] Error “Object reference not set to an instance of an object.” when trying to add links in top navigation bar, as sub menu. With a custom created Sharepoint web template

If you created a webtemplate based on any Site Definition (Team Site…) and if you comment the navbars part

   1: <NavBars>
   2:     <!--<NavBar Name="$Resources:core,category_Top;" Separator="&amp;nbsp;&amp;nbsp;&amp;nbsp;" Body="&lt;a ID='onettopnavbar#LABEL_ID#' href='#URL#' accesskey='J'&gt;#LABEL#&lt;/a&gt;" ID="1002" />
   3:     <NavBar Name="$Resources:core,category_Documents;" Prefix="&lt;table border='0' cellpadding='4' cellspacing='0'&gt;" Body="&lt;tr&gt;&lt;td&gt;&lt;table border='0' cellpadding='0' cellspacing='0'&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='/_layouts/images/blank.gif' id='100' alt='' border='0'&gt;&amp;nbsp;&lt;/td&gt;&lt;td valign='top'&gt;&lt;a id='onetleftnavbar#LABEL_ID#' href='#URL#'&gt;#LABEL#&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;" Suffix="&lt;/table&gt;" ID="1004" />
   4:     <NavBar Name="$Resources:core,category_Lists;" Prefix="&lt;table border='0' cellpadding='4' cellspacing='0'&gt;" Body="&lt;tr&gt;&lt;td&gt;&lt;table border='0' cellpadding='0' cellspacing='0'&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='/_layouts/images/blank.gif' id='100' alt='' border='0'&gt;&amp;nbsp;&lt;/td&gt;&lt;td valign='top'&gt;&lt;a id='onetleftnavbar#LABEL_ID#' href='#URL#'&gt;#LABEL#&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;" Suffix="&lt;/table&gt;" ID="1003" />
   5:     <NavBar Name="$Resources:core,category_Discussions;" Prefix="&lt;table border='0' cellpadding='4' cellspacing='0'&gt;" Body="&lt;tr&gt;&lt;td&gt;&lt;table border='0' cellpadding='0' cellspacing='0'&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='/_layouts/images/blank.gif' id='100' alt='' border='0'&gt;&amp;nbsp;&lt;/td&gt;&lt;td valign='top'&gt;&lt;a id='onetleftnavbar#LABEL_ID#' href='#URL#'&gt;#LABEL#&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;" Suffix="&lt;/table&gt;" ID="1006" />-->
   6:       </NavBars>
   7:   <Configurations>

You might get this error when you create the SiteCollection :

“Object reference not set to an instance of an object.”

You guessed well, all you have to do is to uncomment those line, and prefer to delete it instead of commenting it.

You could also modify the navbar by custom code attach to a feature (with a feature receiver), in order to modify the web template navigation.

[SharePoint 2010 – Error Fixing] SPException invalid date/time (Erreur : Valeur de date/d’heure non valide. Un champ de date/d’heure contient des données non valides. Vérifiez la valeur, puis réessayez)

What did i try to do ?

I’m creating SPListItem Programmatically (create elements in a list) and when the item.update(); is called by the code, the following error is thrown :
“Erreur : Valeur de date/d’heure non valide.Un champ de date/d’heure contient des données non valides. Vérifiez la valeur, puis réessayez”
or in english :
“SPException : invalid date/time…”

What could be the problem ?

  1. The date format is not correct
  2. The date is not correct (minimum date for SharePoint ?)

Solving the problem

I’m giving an example of an incorrect date value “01/01/0001 00:00:00” :

   1: SPList list = web.Lists["myList"];
   2:  
   3: SPListItem item;
   4: string date = "01/01/0001 00:00:00";
   5:  
   6: item = list.Items.Add();
   7:  
   8: item["currentDate"] = date;
   9: if (DateTime.TryParse(row["currentDate"].ToString(), out dateTime) == true)
  10: {
  11:     //si la date est définit
  12:     if (dateTime.ToString() != "01/01/0001 00:00:00")
  13:     {
  14:         item["currentDate"] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Parse(date));
  15:     }
  16: }
  17:  
  18: item.update();
  19: list.update();

01/01/2001 is an incorrect value for a date in sharepoint.

And we check the date in order to respect sharepoint dates rules, using the method : CreateISO8601DateTimeFromSystemDateTime.

Have you ever had other issue with dates and SPListItem ?

Create a free website or blog at WordPress.com.

Up ↑