Friday, October 29, 2010

How to Hide SharePoint Column based on user login in Newform.aspx

For last two days i scratch my head, to hide the required column based on the user login in NewForm.aspx and EditForm.aspx of the list. Initially i tried it by using SharePoint designer without using code and later i tried by using inline code but am unable to achieve it , even though i have an option to achieve.

Finally i achieved hiding of share-point column based on user login in NewForm.aspx and EditForm.aspx by creating custom Webpart.

Create a Class Library in Visual studio and add reference 'System.Web', 'Microsoft.SharePoint'. In the class file include the required namespace specify below.







Add the below code

Create the Strong Name Key in Visual Studio and build the project and deploy the code in Assembly and add the Source Safe tag in web.config under which site you want to enable this web part. Now Activate the web-part under Web-part gallery from the top site.

Now add the custom web part in the NewForm or EditForm page where you want to hide the control. That all

To know about Custom Web part Click here

Wednesday, October 27, 2010

Stsadm operations

· Activatefeature

Activates a feature in the feature collection.

· Addalternatedomain

Adds an internal URL and maps it to one of the five URL zones of a Web application or external resource.

· Addcontentdb

Creates a new content database or adds a database that needs to be upgraded when the url and databasename parameters are specified.

· Adddataconnectionfile

Adds a new DataConnectionFile to the DataConnectionFiles collection for InfoPath Forms Services.

· Add-ecsfiletrustedlocation

Lets an administrator add a file to the trusted location list.

· Add-ecssafedataprovider

Lets an administrator add a supported provider type to the safe provider list.

· Add-ecstrusteddataconnectionlibrary

Adds a trusted data connection to a library.

· Add-ecsuserdefinedfunction

Adds a user defined function.

· Addexemptuseragent

Adds a user agent, which is typically in the form of a search bot, to receive the XML file that contains the data of the form for indexing instead of the HTML rendering of the form.

· Addpath

Adds a managed path inclusion to a Web application.

· Addpermissionpolicy

Adds a user to a policy role for the Web application based on the specified permission level name and corresponding zone.

· Addsolution

Adds a solution file to the solution store.

· Addtemplate

Adds a site template to the template gallery.

· Adduser

Adds a user account to the specified site collection and assigns it to the specified site group.

· Authentication

Authentication provides the user identity input to the authorization process which determines what actions the current user is allowed to perform on a given object.

· Backup

Describes how to back up a site collection, an individual database, a Web application, or an entire farm.

· Backuphistory

Displays a history of backup and restore operations that have been run.

· Creategroup

Lets site collection administrators create new groups from any site collection.

· Createsite

Creates a site collection at the specified Uniform Resource Locator (URL) with the specified user as site collection owner and site collection administrator.

· Deletecontentdb

Detaches a content database when the Web application, database name, and database server are specified.

· Deleteconfigdb

Unprovisions the local machine from the farm and deletes the configuration database (but does not drop the configuration database).

· Deletegroup

Deletes a group created in Microsoft Office SharePoint Server 2007.

· Deletesite

Deletes the site collection with the specified URL from the Web application.

· Deletesolution

Removes a Windows SharePoint Services Solution Package (*.wsp) from the solution store.

· Deletessp

Deletes a Shared Services Provider (SSP) in a Web application when the title parameter is specified.

· Deletessptimerjob

Deletes all of the timer jobs in the Shared Services Provider (SSP).

· Deletetemplate

Deletes a specified site template from the site template gallery.

· Deleteuser

Deletes a user account from the specified site collection and specified site.

· Deleteweb

Deletes a subsite using the specified Uniform Resource Locator (URL).

· Deploysolution

Deploys files related to a solution from the configuration database to individual front-end Web servers in the farm.

· Displaysolution

Displays specific solution or Web Part information in a solution store.

· Editssp

Allows the site collection administrator for the Shared Services Administration site to perform the following functions:

· Change the databases that a Shared Services Provider (SSP) uses.

· Change the SQL credentials associated with the SSP databases.

· Modify the service account credentials.

· Rename an SSP

· Email

Sets the e-mail configuration settings for your server.

· Export

Exports site and subsite data from your Microsoft Office SharePoint Server 2007 installation.

· Import

Imports site and subsite data from your Microsoft Office SharePoint Server 2007 installation.

· Installfeature

Installs a feature.

· Renameserver

Changes the name of the specified server in the configuration database.

· Renamesite

Changes a URL of a host-named site collection to a new URL.

· Renameweb

Changes the URL of a subsite.

· Restore

Explains how a restoration of a site collection, an individual database, a Web application, or an entire farm is performed.

· Restoressp

Creates a Shared Service Provider using a restored database.

· Retractsolution

Retracts the specified solution’s deployment, and removes files from the front-end Web server.

· Scanforfeatures

Scans for new features in the file system, and if new features are present, installs them.

· Setconfigdb

Creates a new configuration database in a farm or joins the local computer to an existing farm's configuration database.

· Setdefaultssp

Sets a Shared Services Provider (SSP) as the default SSP in a farm.

· Setlogginglevel

Sets the Windows event log and trace log logging level for one or more diagnostic logging categories registered in the farm.

· Setsitelock

Sets a value that specifies whether the site collection is locked and unavailable for read or write access.

· Siteowner

Sets the primary or secondary administrator of a site collection.

· Setworkflowconfig

Enables or disables the workflow settings

· Upgradesolution

Upgrades an existing solution. The solution to be upgraded could be either deployed or not deployed; however, the immediate or time parameters apply only if the solution has been deployed.

· Userrole

Adds or deletes permission levels to site groups.

How to create Custom webpart in sharepoint

Createproject

To Get Started with creating Custom Web Part for MOSS 2007 in Microsoft Visual Studio 2008, Open the IDE and create a new C# project, Select Class Library as Project Type. Name It.

Add references to System.Web, Microsoft.Sharepoint.dll






Extend the MyNewWebPart Class from the WebPart Class ( System.Web.UI.WebControls.WebParts.WebPart), and add the code as shown below. The CreateChildren Control would create and add controls to current class. In the below coding I have only added a WebControl.Calender Object. The RenderControl Method is an override for the WebPart Base Class and calls the RenderChildren Method, this causes the Children Controls to be rendered on the Particular HtmlTextWriter passed as a parameter to the method.




Now, strongly name it, Build the dll, and use sn-t or reflector to find the public key token.



After that follow the below steps to deploy

1) Now you have to deploy to your website, so locate the Sharepoint WebSite you wish to deploy this webpart in. This can be done via the IIS Manager under administrative tools. The default ones would be virtual directories that look like GUIDs under "C:\INETPUB\WWROOT\WSS\".

2) Place the dll under the bin directory in the virtual directory.

3) Under the same virtual directory, find the web.config, and add the following to the SafeControls section -

<SafeControl Assembly="ClassLibrary2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=77dfsdf234933833"Namespace="ClassLibrary2" TypeName="*" Safe="True" AllowRemoteDesigner="True" />

Insted of above step you can also directly deploy it in the Assembly if you are an Administrator, and add the SafeControl in webconfig file.

4) Then browse to the WebSite, and go to Site Actions -> Site Settings.


5) On the site settings page under Galleries column click on the Web Parts




6) Click on "New" in the toolbar,as shown below -




7) Find the ClassLibrary2.MyNewWebPart



8) Now switch to 'Edit Mode' of the page where you want to add the calender control,then click on Add a webpart, you should see it in the list that pops up. Add the MyNewWebPart, and under Miscellaneous.

9) Click 'Exit Edit Mode' you will find the output as below.



Source :kethare.in