Sunday, October 5, 2014

Deploy External user control through SharePoint Solution

Today’s topic actually nothing to do with SharePoint. This topic is same for Asp.Net and .Net applications. But I'm going to do it in SharePoint solution.

First Create SharePoint Solution in visual studio.  Open project package.

Capture11

Click on Advanced tab in Package.

Capture12

Click on Add button and Add Existing Assembly.

Capture13

Select the user control from the browse button. Select deployment target as GlobelAssemblyCache.

Add new item in SafeControls section. Fill namespace and Assembly name. Tick on Safe option.

Capture14

This will add dll into globel assembly cache do your job for you. Thank you.

Saturday, October 4, 2014

Multi select check box dropdown lists in SharePoint and Asp.Net (Client side value handling using JQuery)

Today I'm going to bring you one of interesting topic. Normally Asp.Net framework does not provide a Checkbox dropdown list control. Sometimes we got problems with UI aspect when we use Asp.Net Checkbox List control. So its important to keep it short in the page.

After few hours of searching in internet i found perfect solution to make my life easy.  Check box dropdown list. This will make my page shorter cause i got hundreds of values to show. I personally thanking the owner of this control cause this is well written control. Following link will guide you to the solution and the dll file. The solution is still a beta version.

http://www.dotnetfox.com/articles/dropdowncheckboxes-or-drop-down-checkboxlist-control-in-Asp-Net-1100.aspx

http://dropdowncheckboxes.codeplex.com/releases/view/70874

By the way i’m not going to talk about the server side aspect of the control. I found a problem of accessing this control selected values by client side. fortunately after few hours of playing around i found a way to get those values. the problem is with the control name.

Following shows to how to solve it.

First if you are developing web part you need to register this third party control. (Can use in asp.net also dll should gac in to the assembly on both occasions). Then need to add to the page.

Capture1

Capture2

Capture4

Then the stuffs. This is easy to handle in server side but not in client side.  This is how get those selected values to display on caption area in dropdown list by using client side.

Capture3

when getting values from this control we always need to add “_sl” to the end of control id. This will do it for you without a post back. Special thanks goes to Saplin.Controls. Thanks.

Tuesday, September 2, 2014

How to check Signed In User in Site is exist in SharePoint User Groups

Hi.. This is a topic related to SharePoint security. When security levels drilling down to bottom level we always needs to have access permissions on web parts level. Basically we need to grant or deny access permission  according SPGroups of who logged in to the system.  So there are several ways to do that. One is to get the users groups from user object and manually check the specific group. You need couple of string operation and looping. Now that's kind of messy.

But SharePoint provides you an easy way of doing this this. You only need SPWeb object to do that operation. From this method you can easily find out whether current user is in the specific group. Method as follows.
SPWeb.IsCurrentUserMemberOfGroup(web.Groups["SpecificGroupName"].ID)
The mehod requires the SPGroup id you want to search and returns Boolean value.You can use this method as follows


This method will give bool status TRUE if the user existing in provided group.

Just to remind that don't use this inside SPSecurity.RunWithElevatedPriviledges() because SharePoint gets the logged in user as System User.

This will worked on both Claim Based and Form Based users Well.. Thank You..

Saturday, July 12, 2014

Form based authentication Sign Out problem Solution on SharePoint 2013

Hi.. This is my first blog post. I've been finding solution for months for this problem. Normally SharePoint handles the sign out process automatically if the authentication mode is Claim based. But when it comes to Form based authentication or mixed mode authentication it cause some problems.

I experienced when user is going to Sign out from the site it will redirect to Error page. The problem is with the SharePoint itself. Problem occurs when SharePoint is redirecting to "_layouts/SignOut.aspx" page without clearing Cookies and Session objects.

This problem can solve with introducing new user control(web part) to your solution. This user control can place on your master page.
<asp:HyperLink ID="HyperLinkSignOut" CssClass="noBorder" runat="server" NavigateUrl="../../../../_layouts/15/SampleSignOutSolution/Signout.aspx">Sign Out</asp:HyperLink>
you can use either button, link button or hyperlink. In my solution im using another Application page. You can simply create it by adding application page for your solution. following image shows how to add application page.

Add Application Page

After adding the Application page add this code in the page itself. Application page will placed in 15 hive.
Page Load
Page_Load() event of Application Page

Function that called by Application Page Page_Load()









This will do the trick for Form based authentication sign out. From the web part early created you should call this page. link should as follows.
"/_layouts/15/YourSolutionName/YourApplicaitonPageName.aspx"
If your system has mixed mode(Form based & Claim based) you can add another link to previous web part to sign out claim based users also. this is pretty much easy.
<asp:HyperLink ID="HyperLinkInternalUsersSignOut" CssClass="noBorder" Visible="true" runat="server" NavigateUrl="/_layouts/SignOut.aspx">Internal Sign out</asp:HyperLink>
That's all. Hope this will help to resolve the sign out problem with form based authentication. Thank you.

I referance this blog post from Tobias Lekman. It helps me a lot. Thanks.



Tuesday, October 29, 2013

What im going to Post

Hi all,

Im going to post all the technical difficulties i faced in SharePoint development and solutions that i found time to time..

Thanks.. :D