Showing posts with label Basics. Show all posts
Showing posts with label Basics. Show all posts

Monday, August 9, 2010

Silverlight parameters

Scenario:
Silverlight and SharePoint 2010 is great combination. Here's a quick post of how to pass parameters to Silverlight and consume them in Silverlight.

Solution #1: (Initialization Parameters)
This is most commonly used way to pass the values. This is how we declare it.

ASPX(C#)

<asp:Silverlight ID="Xaml1" runat="server" 
Source="~/ClientBin/InitParamsMgr.xap"
MinimumVersion="2.0.31005.0" Width="100%" Height="100%"
InitParameters="param1=value1,param2=value2">
</asp:silverlight>
HTML
<object id="SilverlightPlugin1" width="300" height="300"
data="data:application/x-silverlight-2,"
type="application/x-silverlight-2" >
<param name="source" value="SilverlightApplication1.xap"/>
<param name="InitParams" value="param1=value1,param2=value2" />
<!-- Display installation image. -->
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0"
style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376"
alt="Get Microsoft Silverlight"
style="border-style: none"/>
</a>
</object>
How to use it in Silverlight:
1. Add the following code Application_Startup method.
private void Application_Startup(object sender, StartupEventArgs e)
{
if (e.InitParams != null)
{
foreach (var item in e.InitParams)
{
this.Resources.Add(item.Key, Uri.UnescapeDataString(item.Value)); }
}
this.RootVisual = new MainPage();
}
2. Open MainPage.xaml.cs and add the following method
private string GetParam(string p)
{
if (App.Current.Resources[p] != null)
return App.Current.Resources[p].ToString();
else return string.Empty;
}
3. Use the following code to read the parameter value
string param1value = GetParam("param1");
Solution #2: ( Query Parameters )
How to use it in Silverlight:
1. Add the following code Application_Startup method.
private void Application_Startup( object sender, StartupEventArgs e ){  
this.RootVisual = new MainPage();
string queryParam = HtmlPage.Document.QueryString["key"];
this.Resources.Add( <resourcekey>, queryParam );
}
2. Use the following code to read the parameter value
in XAML
<silverlightcontrol property={StaticResource ResourceKey} />
or in C#
object parameter = ((App)Application.Current).Resources[<Resourcekey>];

Article:
How to pass initialize parameters..

Related and Referred Articles:
MSDN
Decoding paramters

Thursday, August 13, 2009

using SPContext.Current.List

Scenario:
Someone asked me an interesting question , he said he knows about SPContext.Current.Site and SPContext.Current.Web objects and how to use them.

but he is confused where can we use SPContext.Currect.List or SPContext.Current.ListId etc.

Solution:
Its was pretty simple to quickly show him how to use it in a Custom Application List Setting page. Code below.

Note : In layout pages you need to pass the List=<ListGUID> as Query parameter
( Thanks for Chaitu for pointing it out )

Also you can use the list context in any webpart which is sitting on any list pages ( EditForm.aspx , DisplayForm.aspx or AllItems.aspx ) , here you need not to have anything Query parameter for the list guid

ASPX:

<%@ Assembly Name="SPCustomField, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7668d5f62402984f"%> 
<%@ Page Language="C#" Inherits="TestContext.ListSettingTest" MasterPageFile="~/_layouts/application.master" %>

<asp:Content ID="Content1" ContentPlaceHolderId="PlaceHolderMain" runat="server">
<asp:Label ID="lblListName" runat="server" Text=""></asp:Label>
</asp:Content>
Codebehind:
using System;
using Microsoft.SharePoint;
using System.Web.UI.WebControls;

namespace TestContext
{
public partial class ListSettingTest : System.Web.UI.Page
{
protected Label lblListName;
protected void Page_Load(object sender, EventArgs e)
{
lblListName.Text = "List Name : " + SPContext.Current.List.Title;
}
}
}
Result:
test

Sunday, July 19, 2009

List Definition with no search results

Scenario:
Once in a while we need some hidden list to store some information which we programtically want to consume without letting end users know about it.

Another important thing is that search should not display anything from this list.

Solution:
List Definition does support a tag Privatelist to do similar to this.

Example:

<List 
Name="Private Documents"
Title="Private Documents"
Description="This library store some internal documents used with in the site."
PrivateList="TRUE"
Direction="0"
BaseType="1"
Url="PrivateDocuments"
DisableAttachments="TRUE"
Type="101"
Id="NewGUID"
xmlns="http://schemas.microsoft.com/sharepoint/">
.....
</List>
Note:
Earlier in this ( post ) I already showed you how to create an instance of any list with NoCrawl=True , making that particular instance of the list hidden from search results. Above example is different in the sense , that here list definition itself is hidden and so will be all the instances created from this list definition.

Sunday, July 5, 2009

Task List : Claim a task

Scenario:
Discovery continues with sharepoint. While working with Sharepoint Task list , I found a great functionality. Claiming a task.

How does it work:
This feature is available in a unique situation, where the task has been assigned to Group rather than to an individual.

When you assign a task to an Active Directory or Sharepoint Group, you will see an extra menu item, when you switch to Edit Item view Claim Task.When you click the above menu basically it updates the Assigned To field with your name.



Don't worry it still remembers the group behind the scene. Thats why one you claim a task , it will give you an option for Release Task, which basically reverts the change.

Wednesday, May 20, 2009

Customizing site template or list template

Scenario:
First of all you might be thinking , is it possible ? Yes it is possible. SharePoint always have something to surprise you. Till date I was under the impression that Site Template is binary file and can't be edit with editor like Notepad. So I admit i was wrong.

Solution:
Here's the steps to make modification to list template ( stp files )

01. Create a new document library and list.
02. Add items / documents to it
03. Customize the look and feel.
04. Go to List Settings > Save List as template > Give a meaningful name > Submit
05. Download the .stp file locally
06. Rename the .stp file to .cab file
07. Extract the .cab file
08. You will find a manifest.xml file which is the main file
09. Open the Manifest.xml with some XML editor and make changes
10. Save it back and rename it back to .stp file
11. Upload the stp file to List Template Gallery and now you all set use it.

Follow the same set of steps in context of site template ( .stp file ) to make the required modification.

Leave a comment if you having problem understanding the XML.

Tuesday, May 19, 2009

What is .NET RIA Services?

Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. The RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom operations. It also provides end-to-end support for common tasks such as data validation, authentication and roles by integrating with Silverlight components on the client and ASP.NET on the mid-tier.

Friday, May 15, 2009

What is NHibernate ?

NHibernate is an Object-relational mapping (ORM) solution for the Microsoft .NET platform: it provides a framework for mapping an object-oriented domain model to a traditional relational database. Its purpose is to relieve the developer from a significant portion of relational data persistence-related programming tasks. 

NHibernate 3.0 will be the first version to use .Net 3.5. NHibernate's primary feature is mapping from .NET classes to database tables (and from CLR data types to SQL data types). NHibernate also provides data query and retrieval facilities. NHibernate generates the SQL commands and relieves the developer from manual data set handling and object conversion, keeping the application portable to most SQL databases, with database portability delivered at very little performance overhead.

Thursday, May 14, 2009

What is Forefront Security ?

Microsoft Forefront™ Security for SharePoint (FSSP) is the solution for the SharePoint virus problem. Forefront for SharePoint is designed to protect servers running Microsoft Office SharePoint Portal Server 2007 or Microsoft Windows® SharePoint Services 2007. Both versions run on either the 32-bit or 64-bit version of the SharePoint server and have identical functionality.

The configuration data for the Forefront for SharePoint Realtime Scan is stored in the SharePoint Portal Server or Windows SharePoint Services configuration database, and not in a separate Forefront for SharePoint database. This means that you can access the configuration data from either the Microsoft Forefront Server Security Administrator or from the SharePoint Administrator.Forefront for SharePoint also supports the Microsoft Forefront Server Security Management Console (FSSMC). The FSSMC provides administrators with central installation and reporting functionality.

Wednesday, March 25, 2009

Creating List Instance with Default values

Scenario:
I wanted to create a list instance in my site definition with some properties already set including no crawling and hidden.

Solution:
Schema support setting lot of properties.

Code:

<ListTemplate Name="SpecialDocumentLib"
DisplayName="SpecialDocumentLib"
Description="SpecialDocumentLib"
SetupPath="SpecialDocumentLib" Type="101" BaseType="1" Hidden="TRUE"
HiddenList="TRUE" NoCrawl="TRUE" FolderCreation="FALSE" Unique="TRUE"
RootWebOnly="FALSE" Catalog="FALSE" OnQuickLaunch="FALSE" SecurityBits="11"
AllowDeletion="FALSE" Image="/_layouts/image/specialdoclib.gif"
DontSaveInTemplate="TRUE" DocumentTemplate="100" />
</ListTemplates>
Note:
Hidden=TRUE will hide the list definition from the Create page.
and
HiddenList=TRUE will hide the list instance you have created using this list definition.

Sunday, March 22, 2009

Feature Scope Information

Scenario:
This is basically for me and people who sometime get confused to decide the correct scope of the feature. This is so much into SharePoint , hard to remember it all. infact these days I am getting Hard Disk full warnings ( from my Brain ) .. haha

Solution:
Here's the possible scope information.

Web (Web site)

Control
Custom Action
Custom Action Group
Hide Custom Action
List Instance
List Template
Module
Receiver
Site (site collection)
Content Type
Content Type Binding
Control
Custom Action
Custom Action Group
Feature/Site Template Association
Field
Hide Custom Action
List Instance
Module
Workflow
WebApplication (Web application)
Control
Custom Action
Custom Action Group
Document Converter
Feature/Site Template Association
Hide Custom Action
Farm (farm)
Control
Custom Action
Custom Action Group
Feature/Site Template Association
Hide Custom Action

Sunday, March 15, 2009

What is MySites ?

A My Site is a Windows SharePoint Services site collection that provides a centralized location for each user to store and share his or her information—such as photos and documents—with other users, set user alerts, and connect with and track other colleagues throughout the organization. My Sites are created when a user clicks on the My Site link on the main page of an SharePoint Server 2007 site.

Users will feel more in control with the new privacy controls introduced in SharePoint Server 2007 My Sites and will be able to more granularly target their personal information. Custom roll-up Web Parts enable users to easily review their sites and documents,and link directly to that content. The ability to easily connect with other colleagues throughout the organization using specialized My Site colleague Web Parts allows knowledge to be more readily exchanged, enabling users to connect to colleagues with similar interests.

Its like companies' internal Facebook network, also MySites are only available to MOSS only

What is User Profile ?

A personal profile about each user includes properties such as a user’s title, e-mail, distri-bution list membership, and contact details. It is typically imported by SharePoint from a directory such as Active Directory, but it can also be manually created directly inside SharePoint. User profiles can be customized in SharePoint to include additional details, such as birthday and interests. Personal profile are used throughout SharePoint Server 2007 to disseminate or target information to users, help users locate colleagues with sim-ilar interests, and return search results on people.Its available for MOSS only.

Sunday, March 1, 2009

Missing Excel Calculation Service missing

Scenario:
One of my student tried installing Sharepoint and when he wanted to start the required services , he was not able to find Excel Calculation Services.
also links for infopath form server , business data catalog were missing.

Also he noticed Report Center template was also missing.

Solution:
Simply , It was not installed. As by mistake MOSS Standard edition was installed, things were missing.

Actually there is no separate download for MOSS Standard and Enterprise. Features and services are activated depending on Standard licence / Enterprise licence key.

Major difference between MOSS Standard vs Enterprise.
1. Forms Server
2. Excel Services
3. Report Center
4. Business Data Catalog
and more...

Article:
Product Comparision

Monday, February 2, 2009

SharePoint reserved keywords and Query string issue

Scenario:
I faced some issues in past using View as query parameter in sharepoint.That time i changed the query parameter name and everything worked fine.

I never got a chance what was wrong that time and today I was reading an article and got the details solution.

Solution:
SharePoint itself uses some query parameters, you can say they are reserved keywords. Specially when you are using Context.

So If you are trying to get information about Current View , basically SPContext object inpects the query string for the query parameter View and that might create some problem if you are also setting View as query parameter for some other purpose.

Even though this situation is very very rare. Still try avoiding few keywords listed here.

Code:

FeatureId
ListTemplate
List
ID
VersionNo
ContentTypeId
RootFolder
View
FolderCTID
Mode
Type
Article:
Stefan Gossner

Thursday, January 22, 2009

What is SSO ?

SSO stands for Single Sign On. Normally when we are implementing authentication in ASP.NET web application, you have to create a login page for each of your applications. Imagine that you have two or more web application which are related together. So you may want to use a mechanism which allows you to create just one login page for all your related applications. In this way, once you have logged in you can browse other application without any extra login required. Single sign-on (SSO) is a method of access control that enables a user to authenticate once and gain access to the resources of multiple software systems

SSO allow you to accomplish the goal of Cross Application login. In other words, we just want to have one login page for whole web site, and once the users have been authenticated they can browse to other web sites, without the need to re-login.

Wednesday, January 21, 2009

What is MOSS ?

Microsoft Office SharePoint Server 2007
(MOSS) is the full enterprise-ready, collaborative platform product offering from Microsoft, and is definitely not free. The biggest reason (I think) that things get confusing between WSS and MOSS is because MOSS is built on top of WSS. MOSS offers all of the features of WSS, but enhances and extends them while also adding new functionality. So you'll see the same site templates from WSS available to you when creating a new site in MOSS, as well as a host of new options.

There are several features that you get with MOSS that aren't available in WSS:


  • Search and cohesion across site collections - In WSS, each site collection is an island unto itself. MOSS adds the portal umbrella that pulls together those separate site collections and allows for searching across them.
  • Personalization - MOSS allows users to have individual, personalized sites; WSS doesn't. (MySites are an example of a personalized MOSS site and available via a specific MOSS site template)
  • User Profiles - MOSS allows you to import, store, and update personal data on your users, it's not available in WSS
  • Audience Targeting - MOSS allows you to target content to specific user groups; WSS doesn't.
  • Crawl and Index sources outside of SharePoint for searching- MOSS allows you to return search results for indexed sources such as file shares, web sites, Lotus Notes databases, and much more; WSS can only crawl and index WSS sites.
  • Search administration and customization - MOSS gives its admins much more control over the configuration of its search engine; WSS doesn't.
  • Site Templates - MOSS provides additional site templates (and workflows) for content management and portals; WSS does not have these templates.

Thursday, January 8, 2009

Where's sharepoint binaries located ?

Scenario:
Every now and then I want to reference SharePoint binaries, but sharepoint have it scattered all over. OK if not all over, then atleast more than 2-3 places i know of.

Location:

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Config\ADMINBin\Microsoft.SharePoint.ApplicationPages.Administration.dll

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Config\Bin\Microsoft.SharePoint.ApplicationPages.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.portal\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Portal.dll

C:\WINDOWS\assembly\GAC_32\Microsoft.SharePoint.Portal.SingleSignon\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Portal.SingleSignon.dll

C:\WINDOWS\assembly\GAC_32\Microsoft.SharePoint.Search\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Search.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.AdministrationOperation\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.AdministrationOperation.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Diagnostics\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Diagnostics.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Dsp\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Dsp.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Dsp.OleDb\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Dsp.OleDb.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Dsp.SoapPT\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Dsp.SoapPT.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Dsp.Sts\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Dsp.Sts.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Dsp.XmlUrl\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Dsp.XmlUrl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.intl\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Library\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Library.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Portal\12.0.0.0__71e9bce111e9429c\microsoft.sharepoint.portal.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Portal.Intl\12.0.0.0__71e9bce111e9429c\microsoft.sharepoint.portal.intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Portal.SingleSignon.Security\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Portal.SingleSignon.Security.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Portal.Upgrade\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Portal.Upgrade.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Publishing\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Publishing.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Publishing.Intl\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Publishing.Intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Publishing.Intl.Resources\12.0.0.0_en-US_71e9bce111e9429c\Microsoft.SharePoint.Publishing.Intl.Resources.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Search.Intl\12.0.0.0__71e9bce111e9429c\microsoft.sharepoint.search.intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Search.Intl.Resources\12.0.0.0_en-US_71e9bce111e9429c\microsoft.sharepoint.search.intl.resources.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Security\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Security.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.SetupConfiguration.Intl\12.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.SetupConfiguration.Intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions\12.0.0.0__71e9bce111e9429c\microsoft.sharepoint.WorkflowActions.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions.intl\12.0.0.0__71e9bce111e9429c\microsoft.sharepoint.WorkflowActions.intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.WorkflowActions.intl.resources\12.0.0.0__71e9bce111e9429c\microsoft.SharePoint.workflowactions.intl.resources.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Workflows\12.0.0.0__71e9bce111e9429c\microsoft.SharePoint.workflows.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Workflows.intl\12.0.0.0__71e9bce111e9429c\microsoft.SharePoint.workflows.intl.dll

C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SharePoint.Workflows.intl.resources\12.0.0.0__71e9bce111e9429c\microsoft.SharePoint.workflows.intl.resources.dll

Directory of C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI

Microsoft.Office.Excel.Server.Udf.dll
Microsoft.Office.Excel.Server.WebServices.dll
Microsoft.Office.Policy.dll
Microsoft.Office.Server.dll
Microsoft.Office.Server.Search.dll
microsoft.office.workflow.tasks.dll
Microsoft.SharePoint.dll
microsoft.sharepoint.portal.dll
Microsoft.SharePoint.Portal.SingleSignon.dll
Microsoft.SharePoint.Portal.SingleSignon.Security.dll
Microsoft.SharePoint.Publishing.dll
Microsoft.SharePoint.Search.dll
Microsoft.SharePoint.Security.dll
microsoft.sharepoint.WorkflowActions.dll


I know this is not complete listing , but I will add more as and when I will discover more.

Tuesday, December 30, 2008

Where is GlobalAdminPageBase binary ?

Scenario:
I want to add an extra UI to Central Administration. I know most of the pages in Central Administration WebApplication inherits GlobalAdminPageBase class.Dont ask me how I know that but I just know it. :-), anyway , so I inherited the GlobalAdminPageBase class for my new ADMIN Page.

But now how to find out where is the binary for the class.

Solution:
[..]\12\CONFIG\ADMINBIN\Microsoft.SharePoint.ApplicationPages.Administration.dll

Thursday, December 25, 2008

Users vs AllUsers vs SiteUsers

Scenario:
You want to get all the users who have access to the site. An SPWeb object exposes three different collections of users, as shown in this code below.

Code:

SPWeb web = SPContext.Current.Web;
SPUserCollection c1 = web.Users;
SPUserCollection c2 = web.AllUsers;
SPUserCollection c3 = web.SiteUsers;
Explaination:
The Users collection has the smallest membership of these three collections. This collection includes all the external principals that have been explicitly assigned permissions within the current site.

The AllUsers collection includes all members of the Users collection, plus external users that have accessed objects within the site using implicit permissions through group or role membership. For example, imagine a user named Sandeep with the login of LITWAREINC\SandeepN that has never been given explicit permissions to access a site and view a particular list. However, he might still be able to view the list because of his membership within an Active Directory group that has been configured with list view permissions. When Sandeep first accesses the site or one of its objects (say, a list using implicit permissions), he is added as a member of the AllUsers collection, but he is not added as a member of the Users collection.

The SiteUsers collection is an aggregation that combines membership for each AllUsers collection within the current site collection. The membership of this collection includes all external principals that have been assigned permissions to any object within the site collection as well as all external users that have been granted access to any of the site collection's objects using implicit permissions.

Wednesday, November 5, 2008

What are Control Adapters ?

Control adapters are simply a way of providing different renderings for controls without actually modifying the controls themselves. Because control adapters are designed to provide alternate renderings for different clients, you specify control adapter mappings in a .browser file, which is where associations between User Agent strings and browser capabilities are defined.

The control adapter class itself must inherit from the System.Web.UI.Adapters.ControlAdapter, which is an abstract base class that looks much like the Control base class, with events for Init, Load, PreRender, and Unload, as well as a virtual Render method.