Tuesday, November 30, 2010

Google Chrome uses IE login information

Does Google chrome uses IE login settings and information?

No… that would be crazy, right?

But – how else would explain this strange behaviour:

I have a SharePoint site that supports anonymous login. I have IE open and logged in to the site as user A, and in the site the is a tasks list that does not allow anonymous users to view items.

When I opened chrome and browsed to the site home page – as expected, I was still anonymous to the site. But as soon as I hit the link to the tasks list – it logged me in as user A, without even asking for my credentials!

So, Google chrome does not ask for login information? Does it share the login information with IE? This is kind of troubling if true, as so far I used several browsers to make sure I get isolated sessions and logins.

So, I opened IE internet options –> security settings and forced IE to work in anonymous mode only:
image

Now, when I open Chrome and try to access that list it prompts me for user name and password before it logs in.

Am I the only one surprised?

Monday, November 22, 2010

Speaking Engagements 2011

My 2011 speaking engagements are posted below,
If you are around – come see me!
If you were in one of my sessions, you can find links to the session code and presentation below. Also – if you have any comments on my session – feel free to post it here!

January 29 2011 - SharePoint Saturday Hartford - All about the SharePoint Ribbon for developers
January 31, February 2 2011 - SharePoint Summit 2011 Toronto - All about the SharePoint Ribbon for developers

February 1 2011 - SharePoint Summit 2011 Toronto - Upgrading customized solutions in SharePoint from 2007 to 2010
April 21 2011 – Markham .NET user group - All about the SharePoint Ribbon for developers
October 29 2011SPS Twin Cities – Introduction to SharePoint Development using VS2010 and SP2010, Developer’s guide: how to enhance your SP performance: Understanding caching
November 5 2011SPS RichmondAll about the SharePoint Ribbon for developers
January 7 2012SPS Virginia Beach – Session unknown… (technically this is a 2012 speaking engagement…) – Cancelled due to other obligations. Sorry I couldn’t make it!


See you there!
( my 2010 speaking engagements page: Speaking engagements 2010 )

Monday, November 8, 2010

Using jQuery in SharePoint 2010? Here is something you didnt expect!

If you are planning or using jQuery JS library in SharePoint 2010, there is one thing you didn't plan - for sure.
The $ sign from jQuery library is conflicted with the $ sign used in SharePoint JS - only in picture library "thumbnails" view.
Meaning, your code will not work if it has a picture library thumbnail view web part.
A wrong solution would be to append your JS to the end of the page - do this and your code will work, but the thumbnail view will stop working!
The solution for this is rather simple and annoying,
All you have to do is rename the $ sign into something else, like myJQ.
To do this - add this simple line of code at the end of your jQuery JS file:
var $jq = jQuery.noConflict();
and use $jq instead of $.
Note: you should use your own unique key instead of $jq.

Friday, November 5, 2010

Custom List Ribbon Button dont show up on home page

Today I found a strange behaviour,
My custom list and library ribbon buttons were working find within the list page, but as soon as I added a list view web part to the home page or any other web part page - the custom buttons were gone!
Only the OOB buttons were available.

After some fishing aroun the code I learned that the list view property "Show Toolbar" had something to do with that. Once I changed it to "Full toolbar" my custom buttons were available!

Strange though, since the other OOB ribbon buttons appear all the time... well, what can you do?

Cheers

Wednesday, October 27, 2010

SharePoint 2010 Replaceable Parameters

Replaceable parameters is one of the nicest new features implemented for Visual Studio 2010 Tools for SharePoint 2010. I won't go into elaborate detail because this feature is well documented here, here, here and here, just to name a few places. What I do want to do is point out a few things that may help you avoid frustrations.

1. In a standard SharePoint 2010 pr
oject, ASMX files do not get parsed. What this means is that you would have to hardcode your assembly information in these files. But, as MSDN has pointed out here you can edit your csproj to include new file extensions.




GREAT! Now we can have files other than ASPX, XML etc. Our ASMX files, amongst others, are now parsed and the tokens are replaced.

2. When using the following parameters:


  • $SharePoint.Type.<guid>.AssemblyQualifiedName$

  • $SharePoint.Type.<guid>.FullName$


always ensure that the GUID is lower case. I spent hours trying to figure out why this parameter wasn't being replaced. This problem came about because most people, including myself, just used the GUID Generator. The GUID Generator returns uppercase GUIDS. Here is something that will save you time. In Visual Studio you can select the inserted GUID, hit CTRL + U and voila, you now have a lower case GUID. For example

<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>

<
Class>$SharePoint.Type.cd59ef5a-3bc8-409d-ab43-d0a166168f9d.FullName$</Class>

[Guid("cd59ef5a-3bc8-409d-ab43-d0a166168f9d")]

3. SNIPPETS are an amazing feature when used in conjunction with the replaceable parameters. If you go here, download and install the snippets package, you can now right click and insert any of the replaceable parameters directly into your files. No need to look up or remember any of them! SWEET!

I'm not saying anything I've said here is ground breaking, but I'm just trying to save you some time. For me, being able to insert a GUID, make it lower case and then use a snippet to insert the token into my file makes my SharePoint development easier.

Tuesday, October 26, 2010

Site Navigation Tree Web Part goes on codeplex

Finally got the time to put this nice free webpart on codeplex.

We had it on our site as a free download, but now you can get the source code as well!

It also features a very cool, fast and simple tree controls - one of the first tree controls I ever written that use pure ASP.NET - no AJAX or any other framework needed!

http://ssnt.codeplex.com/

Let me know if you like it,
Next - I have to release our "feature visibility" feature (dumb name :) ) - which is a farm feature that allows you to show/hide certain features on specific web applications, site collection or sites.

Again - this one is shipped free with our wiki plus solution and it is about time it will go on codeplex!

Friday, October 1, 2010

Most annoying error message in SharePoint development

How much do you hate this error message: "One of the properties of the Web Part has an incorrect format. Microsoft SharePoint Foundation cannot deserialize the Web Part. Check the format of the properties and try again."?

If you are like me, creating lots of SharePoint web parts - you must have seen this hundreds of times.

See my old post on this issue: unable to add selected web part(s)

It does not give you any useful information as to what went wrong, you cannot debug it and basically you were blind folded to resolve this issue on your own.



What if I tell you, that there is a way to get the internal error message that will let you know exactly what you did wrong in code, DWP, or anywhere else?

Well, as I have learned today - there is such a way, and it is rather simple.

First, you have to make sure your server shows complete error messages and not these nice custom error page. Simply edit your web.config (back it up first!) and change CallStack="false" to CallStack="true", and also change the to

Now, you install your web part, try to add it to a web part page and boom – this happens…
The trick is, to go to site collection settings -> Galleries -> Web parts and find your web part definition there.

Once found – click on the file name link to get a detailed error page with stack trace and everything!

Note, that you will get a complete error message the first time:



And the same limited information all other times:



So be sure to keep the error page open first time until you got all the info you need!

Strange, but at least we got something!

Wednesday, August 11, 2010

Speaking engagements 2010

For those of you who are interested, or just happen to be in the neighbourhood, here is a list of some of my speaking engagements;

July 6 2010 - Mississauga SharePoint User Group - All about the SharePoint Ribbon for developers

August 7 2010 - SharePoint Saturday Denver - Upgrading customized solutions in SharePoint from 2007 to 2010, Delegate Controls: What, Where and How

August 12 2010 - Microsoft HQ in Ft. Lauderdale - Upgrading customized solutions in SharePoint from 2007 to 2010, Delegate Controls: What, Where and How, All about the SharePoint Ribbon for developers

August 18 2010 - Toronto SharePoint User Group - All about the SharePoint Ribbon for developers

September 11 2010 - SharePoint Saturday EastBay - All about the SharePoint Ribbon for developers

September 18 2010 - SharePoint Saturday LA - All about the SharePoint Ribbon for developers

September 25 2010 - SharePoint Saturday Boston - All about the SharePoint Ribbon for developers

October 2 2010 - SharePoint Saturday UK - Cancelled due to travel limitation

October 16 2010 - SharePoint Saturday DC - All about the SharePoint Ribbon for developers

November 13 2010 - SharePoint Saturday Toronto - All about the SharePoint Ribbon for developers 

December 17 2010
- SharePoint Saturday Boston Webinar - All about the SharePoint Ribbon for developers

January 31, February 2 2011
- SharePoint Summit 2011 - All about the SharePoint Ribbon for developers *

So, see you there!

If you are interested in inviting me to speak at your event, or if you are interested in speaking at the Toronto SharePoint User Group - Please email me to shai at kwizcom dot com.

* - Working on a special lab for this event!

( my 2011 speaking engagements page: Speaking engagements 2011 )

Monday, August 9, 2010

Upgrading customized solutions in SharePoint from 2007 to 2010

This is an updated version of the session given in Microsoft’s SharePoint 2009 conference in Vegas, and other SharePoint Saturdays events.

Delegate Controls: What, Where and How - Updated

Here is the updated presentation from SPSDenver:

Note: Code example is embedded in the power point file so you have to download to get it.

Tuesday, August 3, 2010

Assembly redirection in WSP

Recently I have started upgrading our utilities to the new SharePoint 2010 version,

One of my main goals there was to get rid of the MSI installer we had to use on our products for SharePoint 2007, and go with a "cleaner" installation process of using the SharePoint WSP package alone.

One of the challenges was that as an ISV we have no control over our customer's server, setup or versions installed. Which means, any customer may have any mix of products and versions at the same time.

For example: say we have 2 products - ProductA and ProductB (both at version 1.0.0.00) that were build using our shared utilities DLL: utilities.dll version 1.0.0.01

A month later, we add a new feature in our utilities.dll that is used on ProductB, so now we have upgraded our utilities to version 1.0.0.02 and our ProductB to version 2.0.0.00 and we publish that to the Internet.

Now our customer upgrades his copy of ProductB only.
We had 2 options here:
1. keep both utilities version
2. upgrade and keep only version 1.0.0.02

The first option was no good, since for example our utilities declare a feature called FeatureA. if 2 different packages declare that same feature, and one of them is retracted later on - the feature will be uninstalled with it (There are some other issues like this one, but this is not the scope of this article).

So, sticking with the second option was pretty simple: just install the latest version of utilities with no other older versions of it anywhere.
The only issue was, How will it "tell" all other older products (ProductA) to start using utilities.dll version 1.0.0.02?!

I have looked everywhere for a solution that was just under my nose.

Apparently in VS2010 and SharePoint 2010 there is a new XML node in the package XML definition, right next to the assembly "SafeControls" node.

This new XML node is called "BindingRedirect", and it allows you to specify in the solution package itself any Assembly version redirection you might need!

Problem is - the package designer does not expose this property, so you have to enter it in the Package.Template.Xml directly.

here is how my package.template.xml file looks like:

The end result is:

And this simple produces the following entree in the web.config:

Now, as far as I tested:
  1. Retracting solution cleans this entree up with no problem!
  2. Deploying a new version upgrades this entree and does not create duplicate entrees!
  3. It is safe (like in my example) to give a wide version range in the oldVersion property - even for future versions that do not exist yet. it will simply allow you not to update this every time you build a new version.
So far, this solution had worked out perfect for me, and it is by far the easiest and most simple way to do it in SharePoint than any other way I found on the web - so hope this helps any of you.

Cheers, Shai.

Monday, July 26, 2010

All about the SharePoint Ribbon for developers

Hi all,

I have recently finished working on a new session for developers that I am scheduled to deliver on several user groups and SharePoint Saturdays.

I thought it might be a good idea to post the power point and source code samples online for you to be able to use these samples in your own projects.

This power point and source code includes detailed information on how to customize and manipulate the SharePoint 2010 server ribbon.

The target audience is experienced SharePoint developers.

Note: there is a readme file in the visual studio 2010 project with a script on what's in the source code and how to demo it.

Feel free to comment on the materials here, or if you've attended the session - comment on how did the session go.

I strongly suggest downloading the file rather than viewing it online, you can find it here (to download use the menu at the bottom left):

(Sample source code is embeded in the power point file, so you have to download it to get it)
Thanks, Shai.
=~=~=~=~=~=~=~   Update   ~=~=~=~=~=~=~=
I moved this session to prezi format, source code still inside slide share PPT, but I think the slides part is better in the new format:
http://kwizcom.blogspot.ca/2012/07/i-luv-my-prezi.html

Monday, July 5, 2010

SPRibbon.GetCurrent(this.Page).MakeTabAvailable(); not found

If you try to work with contextual tabs, you might want to use server side in order to make these tabs visible.

Please see a link here to a good article about this by Chris O'brien:
https://www.blogger.com/comment.g?blogID=4126985520350746834&postID=8665495763806155424


But, if you just create a new SharePoint solution these methods will not be available to you:
SPRibbon.GetCurrent(this.Page).MakeTabAvailable();
SPRibbon.GetCurrent(this.Page).MakeContextualGroupInitiallyVisible();

The reason is, that these 2 new commands are infact a part of Microsoft.Web.CommandUI DLL, which is available outside of the SharePoint DLL, hence when you only have a reference to SharePoint DLL's you will see the SPRibbon object but some functionality inherited from it's base type will be hidden.

So - add a reference to Microsoft.Web.CommandUI and you'll be good to go!

Visual Studio 2010 for SharePoint - need more templates?

If you (like me) wished there were more templates in Visual Studio 2010 for SharePoint, like Ribbon control or other cool features - your prayers have been answered here:

http://code.msdn.microsoft.com/vsixforsp

After installing this I was able to add a new component to my SharePoint project named "Server Ribbon"!



Hope to see much more of these in the new future.

(You can also find this useful post on "SharePoint 2010 Extensibility Projects: Server Ribbon" by Paul Stubbs ).

Enable or Disable buttons in SharePoint Ribbon

A few days ago I was doing some reading on the web and I ran across Chris O'Brien post on the ribbon:
http://www.sharepointnutsandbolts.com/2010/01/customizing-ribbon-part-1-creating-tabs.html

(very good post, recommended to everyone if you want to get to know the ribbon better!)

In the first part of this post there is a sample ribbon tab with 4 buttons dependent on one another.

Meaning: clicking one button should enable or disable other buttons on the ribbon (Same tab, different groups).



This was supposed to be easy to achieve using the "EnabledScript" attribute on the CommandUIHandler associated with the buttons needed to be changed.

In my RTM machine, clicking one button did not change the status of the other buttons. After a little research I learned that other examples of enabling a button based on selected list items do work.

I then figured out that were was some update or refresh code running when selecting a list item that was not running during a click on my ribbon button.
This led me to find that in Chris's example, if I select an item after changing the flag - the buttons get enabled as they should!

To keep it short, there is a Javascript method called "RefreshCommandUI" that gets called after certain events in SharePoint (Like selecting an item in a list view) which is responsible to handle all updates of the ribbon.
These updates include:
1. Showing or hiding a contextual tab based on context
2, Enabling or Disabling buttons in the current active tab

Note, that this command does not run on buttons that are not active, but as soon as your tab will become active it will trigger the "EnabledScript" so not to worry!

Anyway, Thanks Chris for the great post, I hope this little fix here will make your ribbonizing experience even more smooth and worth while!

Shai Petel.

Monday, June 21, 2010

Error 500 after installing SharePoint 2010 and Visual Studio 2010

Hi all,

Just and update on some frustrating behaviour I recently had.
The solution is so simple it's annoying to let anyone else struggle with it...

Well, I went ahead and installed SharePoint 2010 on my Win7 64 bit laptop.
In stand alone mode, everything was going great!
here is a link to a great step by step guide for doing that: http://msdn.microsoft.com/en-us/library/ee554869.aspx

OK, once I was done - SharePoint was working great and at lightning fast speed!

Next I wanted to install Visual Studio 2010 on that same machine, so I ran the installer and chose to install C#, Web developer and among other things the SQL express that comes with it.

Installation, again, was going smoothly.

After a reboot - I noticed that SharePoint had stopped working, and any page I tried to access gave me server error 500... even the central administration!

Naturally, I ran the SharePoint configuration wizard and hoped it will make everything better again... only to find out it reports that my configuration database is not available!

So, first step was to fix the DB not available thing... that was easy:
apparently installing VS with its SQL express had stopped the SharePoint SQL instance and all I had to do was to start it, using services or using the start menu -> "SQL Server Configuration Manager":


OK - that allowed me to complete the SharePoint configuration wizard, but did not resolve the server error 500 I keep getting hitting any SharePoint page.

SharePoint log files were useless, which means that the error came before SharePoint code was even called.

Windows log viewer was very helpful on this, reporting an ISAPI filter that could not be loaded and caused the site load to abort: "Could not load all ISAPI filters for site/service. Therefore startup aborted"
Followed by another message:
"ISAPI Filter ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll’ could not be loaded due to a configuration problem. The current configuration only supports loading images built for a AMD64 processor architecture. The data field contains the error number. To learn more about this issue, including how to troubleshooting this kind of processor architecture mismatch error, see http://go.microsoft.com/fwlink/?LinkId=29349."

After a little trial and error, I have noticed that the ISAPI filter DLL file is being loaded from the 32 bit framework folder. Changing that manually to 64 bit in all my sites solved the problem!
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll

So, while I am not sure of why this is happening, but at least here is how to fix it!

Wednesday, June 16, 2010

Running 64bit VM on Win7

With the SharePoint 2010 released, we are all bounded to work on 64bit OS's, and my choice is still to virtualize since I can abuse the system as much as I want and revert back to original in seconds.

So, the problem is that the best performance we've got is when running win2k8r2 64 bit host and using hyperv to run win2k8r2 64 bit VM on it.

Works like a charm on my PC, but what happens when I want to have that VM accessible on my laptop? I do like my win7 there, and don't want to install win2k8 since it is a multi touch tablet which many things are not supported with a server OS.

Well, the options are to either use the boot from VHD option, which in my case was a pain since I had the VM created in and for hyperv.

The Other option I found was to install VirtualBox(.org) which let me run 64 bit VMs on my windows 7.

It also runs VHDs, most if not all - just straight out of the box.

I hit a problem with the latest one that when I booted a VHD created in hyperv into my VirtualBox it would boot into a blue screen every time.

The solution was amazingly simple though, glad I thought of it and didn't give up: See, when creating a new VM in VirtualBox, the VHD is added through a SATA controller. All I did was to remove it and add the same VHD using an IDE controller and boom! It worked!

(this was after a lot of trial and error of course... :)

Well, if you run into a blue screen in VirtualBox - Be sure to try and change the HDD controller!

good luck!

Tuesday, June 1, 2010

Sandbox solutions - Good or Bad?

Hey,

I have seen a lot of guys talking about sandboxing in SharePoint - if its a good thing or a bad thing to do.
I just thought I add my two cents as most of what I think about that subject was not covered by any of these posts... So I am beginning to think I'm a lone wolf.

Good

When are sandbox solutions actually are useful
The main benefit of sandboxing a solution as I see it is either when you wish to pilot a custom solution or a product for a trial period (and afraid it will have a bad impact on your farm), or when you wish to deploy a solution that was built for 1 department, and only they will use it within 1 site collection.
Sandbox allows your site owners to basically upload custom built code and run it off your server.
Scary, eh? I agree.
This is why Microsoft has limited the things and resources you can access within your sandbox solution. Otherwise, it would have been a security breach and no one would have use it - so please, stop complaining about the limitations that comes with it! So, to sum it up:
- Limited access, more secure
- Deployed using a browser, no need to access server
- Has no effect outside current site collection, safer to test / pilot anything risk free
- Easy to monitor

Bad

When sandboxing is not good for you
Overusing sandboxing is not that good, or may not be good for everyone. See, because of the optional security risk involved with sandboxing, Microsoft had to apply some restrictions on these solutions. As a part of the solution for this risk, a sandboxed environment is created for each instance of the solution that is deployed. This environment includes separate storage of the solution files, separate process that runs its code and separate memory to go with it. Imagine you have 400 sandboxed solutions, or just one that is deployed in 400 site collections - clearly this would be a huge waste of resources. Another good/bad thing (you decide) is that once you want to upgrade a sandbox solution that was deployed in 400 site collections - you need to do it manually one by one (or powershell it). Some consider this good as it allows you to test the new version before you deploy it everywhere. I consider it bad since even if you deploy it in full trust you can still pilot the new version as sandbox solution, right? :). I am ignoring of course of the limitations in sandbox solutions that might prevent you completely from using them, which are well covered in other blogs including how to overcome most of them using proxies, or storing resources in an assets library etc... So, to sum it up:
- Waste of resources
- Requires stronger servers or dedicated server to get same performance as full trust
- Hard to manage / upgrade

Ugly

When are sandbox solutions cross the line and start being just stupid
Some of the things in sandboxed solutions are just plain stupid, and do not make sense in security considerations for me at least. Like, say you deployed a sandboxed web part and added it to your page - you tested it and saw it is working OK. After a week of testing you retract the solution and deploy it as full trust. The dll is the same, the web part is the same, but it will no longer work on pages you added it before! you have to remove it and re-add it... Another thing that I cannot explain is why Page.ClientScript.Register**** methods do not work. As soon as I deploy as full trust the same code works like a charm. What is the security risk in using this API I wonder... I can just use the render method to write the same HTML to the page after all, no? Last, as I understand why sandbox solutions cannot access the hive folders, I do not understand why Microsoft did not implement some sort of virtual folders that allows you at least add resources and ASCX files for use withing your solution. So to sum it up:
- Have to remove, re-add and re-configure web parts when switching between deployment methods of same solution
- Cannot use Page.ClientScript to register scripts
- Cannot add resources in a simple way that will be the same regardless to which deployment method my customer chooses.

Please feel free to comment and give your input on this, I will try to update if and when I have more to say on the subject.

Monday, April 5, 2010

SharePoint Bug in Task Status and Priority Fields?

While developing our mobile UI for SharePoint collaboration (KWizCom SharePoint Mobile Extensions) I think I stumbled upon this SharePoint bug, which to my surprise I did not notice it until now - and none of my customers ever did!

It is very simple to find, All you have to do is create a new team site, and go to Tasks list.

There you will have 2 choice fields - Status and Priority.
Both are not required, and both have default value.

Funny thing is - in edit / new item, you cannot choose empty value for these fields.

Wanna see more? Create an item and non-empty status/priority.
Next - go to these fields settings and clear the default value.

Now - you can create new items with empty status / priority, but you cannot remove the value from and item that already has a value there.

Interesting... I have to check if this still happens in 2010... :)

Monday, March 22, 2010

Feature * for list template * is not installed in this farm error

Ok,
So I got this error few times now I thought it is about time to post on it.

I always fall for the same "trap", I get this error when trying to access the list.Forms collection, which is useful for getting the display, edit or new form of a list or library.

But - if some one happened to delete, move or rename one of the default forms of your list - you will get this exception trying to get to this collection:
"Feature * for list template * is not installed in this farm error"


So, keep that in mind and call this collection in a try catch block, and feel free to display this error message in the "catch" block:
"Don't delete built-in list forms!"


What you should do it add new custom forms and redirect to them - but never touch the default ones in SharePoint Designer!

Good luck to you guys,
Shai.

Thursday, March 11, 2010

How to get SharePoint KPI value in C#

It's been a while since I had anything smart to say, and then I had to go and play with KPIs...

KPIs in SharePoint 2007 are pretty cool, they allow you to work in several ways basically: Either you enter the KPI info manually, or you connect it to some sort of a data source like a list, excel file or other providers.

in the end you find your self with a nice list item that has some KPI fields to hold the goal, warning and value levels (in C#: double).

the problem is that when you try to access these fields in code you find that only the manual KPI actually holds the information for you to display:

value = (double)item[list.Fields.GetFieldByInternalName(MobileConstants.KPIHelper.Field_Value).Id];
goal = (double)item[list.Fields.GetFieldByInternalName(MobileConstants.KPIHelper.Field_Goal).Id];
warning = (double)item[list.Fields.GetFieldByInternalName(MobileConstants.KPIHelper.Field_Warning).Id];


Meaning, if you have a KPI that loads from a SharePoint list or an excel file... don't hope to get anything from these fields...

Well, after hours of diggin into SharePoint dll's, I have found the solution finally.

It appears that the entire KPI API ( :) ) is either internal or private to these DLL's, which means of course - reflection!

So I dug in and found some cool examples in MS code that loads KPIs and display them, which in turn exposed some key classes and methods that would save the day.

First one - is the KpiFactory. This guy will in turn get us a Kpi object based on a KPI list item (yes, simple SPList.Item object).

Once we got the Kpi - it is safe to call GetKpiData with no parametes to get another object named KpiData, which finally holds a Value, Goal and Warning properties!

So the final code should look like so:
Assembly asm = System.Reflection.Assembly.Load("Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
Type t = asm.GetType("Microsoft.SharePoint.Portal.WebControls.KpiFactory");
MethodInfo mi = t.GetMethod("GetKpi", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, null, new Type[] { item.GetType() }, null);
object kpi = mi.Invoke(null, new object[] { item });
mi = kpi.GetType().GetMethod("GetKpiData", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, new Type[] { }, null);
object kpidata = mi.Invoke(kpi, new object[] { });

value = (double)ReflectionUtility.GetPropertyValue(kpidata, "Value");//double
warning = (double)ReflectionUtility.GetPropertyValue(kpidata, "Warning");//double
goal = (double)ReflectionUtility.GetPropertyValue(kpidata, "Goal");//double


Of course there are some unclear parameters that have to do with filter and other things, I will update as soon as i figure out what they are for... no idea for now - but at least our mobile solution will have nice KPI's to show after all!

Friday, January 15, 2010

SharePoint 2010 Enable Developer Dashboard via stsadm

Those of you who know me knows how much I don't get along with PowerShell.

When I will get some spare time I will write a "CSharpShell", which will basically allow me to use .NET syntax...

But in the meanwhile, I always find myself looking for that one line of STSADM command to enable developer dashboard in STSADM... so i thought i might post it here:

stsadm -o setproperty -pn developer-dashboard -pv on
or
stsadm -o setproperty -pn developer-dashboard -pv ondemand

enjoy...

Encode in JS Decode in C# problem

Just a quick one guys,

Recently we had a customer who complained about French tags that are not working with our tagging feature (field type, tag cloud for SP 2007 - pretty cool actually).

Well, apperantly we were doing some encoding of text in javascript using "escape()" and trying to decode it in C# on the server side using UrlDecode with no luck.

the text: "de l'entité" was not decoding correctly.

After trying to figure our whats wrong on the server side decoding function (I tried several alternatives) I almost gave up with no success whatsoever :(

So, I turned to look for alternatives in the Javascript encoding and found this new method called "encodeURI()". Apperantly this method can safely replace our "escape/unescape" in Javascript only it supports proper encoding and decoding with C# with no problems.

Works like a charm - from now on, use "encodeURI/decodeURI"!

Cheers, Shai.