Welcome

Sharepoint lead is a place where you can read about interesting topics related to sharepoint, and you can also post comments and suggessions.

Friday, July 25, 2014

Cross site list view web part anywhere in site collection

No comments:

Introduction

There are times when you want to display list/library from root level site collection or visa-versa to sub-site but stuck because sharepoint don't provide list view web part that can be shown across sub sites. If you are in same site collection, its possible with the trick I am going to share.

Step 1 - Create a page and drop list view web part there

Create a page in the site/web where you got the list/library and drop the list view web part into that page and save the page.

Step 2 - Export lsit view web part

If you try to see the edit menu for the web part and there is a link called "Export" you can directly export and download the web part.

If you can not see "Export" option in the web part menu, you have to do following:
  • Right click on the web part content heading that shows list/library fields and click on inspect element (IE9+, chrome, firefox and other popular browsers)
  • Once you are ready with web part id, you can use following url to export the web part
http://root-site-url/_vti_bin/exportwp.aspx?pageurl=page-url&guidstring=web-part-guid

Step 3 - Set Web ID

  • Switch to powershell and get guid of the web where the list exists. $w = Get-SPWeb -identity url-of-web;w.ID
  • Open exported .webpart file and find WebID property and set value of the guid you get to the value in WebId node in web part file.

Step 4 - Upload it to web part gallery

  • Go to site settings > Galleries > web part galleries
  • click on upload and upload your web part file here and set title, group and description of the web part

Step 5 - Finished

  • Go to anywhere in your site collection and add the web part. It will show you the list view web part that you uploaded in specific group.

Limitations:

I tested this with list/libraries having html as default view and rendering of the list view web part works. There are lots of functions associated with the list/library that can be performed from ribbon that I have not tested. Please make sure you consider that while using this trick.

Wednesday, April 23, 2014

ascx.g.cs Empty

No comments:
Bug:
In Visual Studio 2012, when you are working with a visual web part, your user control's ascx.g.cs file becomes empty. So you get an error "The name ‘InitializeControl’ does not exist in the current context".

Root cause:
This is reported as a bug in visual studio 2012 and it generally happens when your server side mark up is having issues. This ONLY happens when you are editing your ascx file.

Suggested Solution:
You can try following:
Short way:

  • try to undo some of the last changes in ascx file.
  • Create copy of ascx file and revert it from source control. Rename g.cs to g.txt and switch to ascx and hit save. That will generate another g.cs with correct content

Long way:

  • Please check the @Register declarations against the TagPrefix and TagName that you are using.
  •  Try to comment out all controls in ascx and save it. That will generate ascx.g.cs along with content again. Now start un-commenting the controls one by one.
  • In worst cases, after trying lots of things people also switch to new web part and migrate useful code from the problematic web part step by step to resolve the error. 

Wednesday, April 16, 2014

Keep it up

No comments:
Sometime back when Rajasthan Royals won the first IPL, I was working with Virtual Lifestyle Pvt Ltd, and CEO Vikas Sabnani explained how Rajasthan Royals being a cheapest team, won the game. Here are three things that he noticed that applies to every team and team players of the world.

  1. Focus on Quality
    Being an important member of the team, if you do so, you are not achieving for yourself and team at the same time. Focusing on quality is as easy as you read it.
  2. Be Proactive
    Here is what the definition says: "creating or controlling a situation rather than just responding to it after it has happened." There are great example of proactive work but in our software world, detecting & fixing or implementing stuff ahead of time with the best suited and most efficient way
  3. Have fun!
    Having fun with what you do is also as important as the other two.
If you are doing it all three together, you are doing it right! If not, what are you waiting for?

Sunday, January 6, 2013

System.ArgumentException: Exception of type 'System.ArgumentException' was thrown. Parameter name: encodedValue

4 comments:
I was configuring one of our clients farm which required FBA on different web applications (around 5) and he wanted each web application should have separate user store. That was too tricky since you just need to set up Application property of the membership provider and you are done.
After completion of these settings, all of my applications were having a common exception either in log out or login to the web application. Here was the exception.
System.ArgumentException: Exception of type 'System.ArgumentException' was thrown.  Parameter name: encodedValue    at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(IClaimsIdentity claimsIdentity, String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager.GetProviderUserKey(String encodedIdentityClaimSuffix)     at Microsoft.SharePoint.Utilities.SPUtility.GetFullUserKeyFromLoginName(String loginName)     at Microsoft.SharePoint.ApplicationRuntime.SPHeaderManager.AddIsapiHeaders(HttpContext context, String encodedUrl, NameValueCollection headers)     at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PreRequestExecuteAppHandler(Object oSender, EventArgs ea)     at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
After checking all my steps right through starting. After getting all the other exeptions cleared the above exception was the only exception that I was getting. That was resolved using "Exception of type 'System.ArgumentException' was thrown" got error when i have signout from webapplication in sharepoint 2010?.
I hope this will help to you if you are getting same error due to a silly custom property of a custom web part for registration!

Update - 5/19/2014

There are several solutions that I tried:
The same error also encountered again reported by client when he tries to enable intranet through internet explorer settings. Disabling detection of intranet from internet options solves that issue but you are forced to enter username password every first visit of the site even in intranet as well!

Update - 5/25/2014

This is a SharePoint bug also found some discussion here: https://sharepoint2013fba.codeplex.com/workitem/9 

Hope this helps