Wednesday, December 1, 2010

CAML vs Linq : round two

A while ago I wrote a post about CAML And Linq when working on MOSS, that post was giving an example of what and when to use each one of them ( when you work on MOSS).

Since that post, a newer version of SharePoint came out, the 2010.
Which is definitely worth writing another part ( update ) for that post.

Actually, I should start with the end result, now you can use Linq in all cases and you will get same results ( only in SharePoint 2010 ).

Now, there is the - how come ? Answer : SPMetal.

What SPMetal does ? In a nut shell, creates an entity class that provide another layer in which your Linq code can access directly to the database ( content db ).
Which is in other words, give you the same performance you could only achieve with CAML queries.

So, if you work with SharePoint 2010 you can work with Linq always. You got my approval :)

Thursday, November 4, 2010

GridView value set to null when column is not visible

You made an Update method to take care of updating your gridview, but there are some columns that are not needed to be shown in the default gridview but you do need them in the update method.
Then, when you try to use those columns data in your method, you will see they have null even though they had value in them...

What can you do then ?

Write those column name in the DataKeyNames section of gridview control. Then, those columns will be available and not with null value in your update method.
 



Good luck.

Saturday, October 16, 2010

How to save scroll location after postback ?

There are two options for that - to implement it with javascript or server side.

The server side implementation is very simple, we will have to do a small change in the web.config file.

 





Be aware - more work on the server side, more memory being consumed. But this method is very quick to implement.

Good Luck.

Sunday, September 12, 2010

"FileNotFoundException was unhandled" SharePoint 2010 newbies error

היי,

את השגיאה שבנושא קיבלתי בעת הרצת האפליקציה על מכונה חדשה שהתקנתי.

בעת הרצת אפליקציית קונסול יש לוודא לאיזו פלטפורמה מגודרת האפליקציה. כברירת מחדל , אפילו על מכונת 64 ביט, הויז'ואל סטודיו מותאם לרוץ לפלטפורמה של 32 ביט. לכן בעת ריצה ושימוש בקלאסים של שרפוינט , אנחנו נעוף מהסיבה הפשוטה שהם מותאמים ל 64 ביט, אז ברגע שננסה להשתמש באובייקט ששייך לשרפוינט נעוף על השגיאה שבנושא.

הפתרון פשוט מאוד - לכו להגדרות הפרויקט/אפליקציה שלכם , ועדכנו תחת הגדרות הבנייה (build) שזה ירוץ על סביבת 64 ביט.

שימו לב, שרפוינט רץ היטב רק בדוט נט 3.5 אם תחליפו את הפרויקט שלכם ל4 ( למשל , בשביל להשתמש ביכולות יותר מתקדמות לרכיבי אופיס ) גם תקבלו תעופה.

בהצלחה.

"FileNotFoundException was unhandled" SharePoint 2010 newbies error

Hi,

Some error that I had just when I started working on the SharePoint 2010 machine. I tried to investigate the SharePoint 2010 API , but surprisingly even trying to create an SPSite object cause a runtime error.

The reason is that you Visual Studio is set for running a 32 bit application, and SharePoint 2010 is 64 bit of course.

The only thing you need to do is to go to the properties of your application/project, then change under the Build tab - the platform target to x64.

Now re-run your console application.

Done.

Tuesday, August 10, 2010

Unexpected Error - When attempting to check "User notifcations". BUG!

Hey,

Today I came across with a very annoying bug when you try to get into the "user notifications" under "site actions".

When you press that link you might get an "unexpected error" - with not much info in the event viewer, nothing if you change the custom errors to off ( in the web.config ). That made me read the Moss log and to see that im being thorwen away with THE famous error AKA "null object refernce".

This made me realize that from some odd reason I have nothing under this link or in other words its not initialized at all...

Then I made a subscription in that web site to some doclib and afterwards I was able to reach that page ( sub*.aspx , forgot the name :) ) and to see that info. Deleting my subscription made the page unavilable again.

So instead of checking if the site has any subscription at all and just prompt some more friendly message or letting you know that there is no subscription to the site -it throws you off with this unexpected error...

It always unexpected when you program wrong. Please check for Nulls.

Thanks.

**This issue was checked on a Moss farm with SP2 and Cumulative update June 2009

שגיאה בלתי צפויה - התראות משתמש

היי,


היום לצערי נתקלתי בעוד באג בפלטפורמה המופלאה שלנו...


כאשר מנסים לגשת באתר תחת "הגדרות אתר" ל"התראות משתמש" מקבלים את ההודעה הברורה - "שגיאה בלתי צפויה"


לצערי לא היו לוגים רלוונטים ברמת השרת, לאחר שינוי ברמת האתר הוירטואלי לראות לוגים ע"י שינוי ה custom erros ברמת ה Web.config


בסופו של דבר נברתי בלוגים של המערכת וראיתי שאני עף על שגיאה של

"The object reference set to null"


דבר שהוביל אותי לחשוד שאני מצביע על כלום איכשהו, ואז נפל לי האסימון שככל הנראה אני עף כי אין בכלל מנויים להתראות ברמת האתר הספציפי הזה...


ברגע שהוספתי מנוי התראה לרשימה כלשהי באתר, האפשרות "התראות משתמש" חזרה לעבוד, הסרת המנוי החזירה את השגיאה...


מילות סיכום, אם אין מנויים באתר - אין אפשרות לראות "התראות משתמש"



תודה.