Tuesday, September 28, 2010

Remove user acess from sharepoint site.

If some user is no longer with company and you want that user not get permission to access SharePoint site and mail go to that particular user.

If you remove the particular user from AD or disable the account in AD, the mail account also disable and the user not get mail.

For remove the particular user use following steps:-

1) Go to Central Administration àApplication Management àPolicy for Web Application

2) Click on Add Users. Select Web Application for which you want to disable access.

3) Select Zones as (All Zones) and click on next button.

4) Add user in Choose user section and select “Deny All – Has no access ”.

5) Click on Finish.

6) The particular user not gets access to the particular site collection.

Thursday, September 23, 2010

Hide/Remove Title Column from List

Many times i thought that there must be a way to get rid of this Title column, because it's name does not suit the business requirements most of the time.


Better way to hide that column from list. Follow the steps mentioned below:-


1)Go to Your list settings on which you want to hide/remove title column.
2)Go to advanced settings of that list.
3)Click on yes at Allow management of content types.
4)Once you do this, one more setting panel becomes visible in advanced settings options. check out the figure below.

5) Now click on Item content type.
6)Click on Title under section Columns.
7)Select radio button "Hidden (Will not appear in forms)".
8)Click on OK button.
9)The column hide from Add.aspx and Edit.aspx page.
9)Go to AllItem.aspx page and hide column in view also.

Remove link on Lookup Field in List

When we add lookup column to any list item add item, the link appears on lookup column. If you check the link, link something like "http://Site/ListName/DispForm.aspx?ID=ID of that field>>&RootFolder=*". 


we find all the Anchor element of the document and check index of href attributes "&RootFolder=*". If you get this attributes simple remove link of lookup.


Add "Content Editor Web Part" webpart on AddItem.aspx page of list. Add the following javascript in webpart:-


<script language="javascript" type="text/javascript">

_spBodyOnLoadFunctionNames.push("RemoveLookupLinks");
function RemoveLookupLinks()
{
var oP = document.getElementsByTagName('a');//the collection of <a> tags
var flag = false
for(var i=0;i<oP.length;i++)
{
if(oP[i].attributes["href"].value.indexOf("RootFolder=*")!= -1)
{
var linkvalue = oP[i].innerHTML;//value of the lookup field
oP[i].parentNode.innerHTML = linkvalue;//replacing value of the lookup to whole the Anchor tag
flag = true;
break;
}
}
if(flag)
RemoveLookupLinks();
}
</script>






Turn Off Send mail option when user add to group.

When we add user to group there is an option "Send E-Mail" and the check box by default selected. Many times
 on client machine when we add the user to group mail fired to user due to this functionality.

If you want to turn off  "Send Mail" option go through following steps:-

1)Open Program Files -> Common Files -> Microsoft Shared -> Web server
extensions -> 12 -> Template -> Layouts  

2)Open AclInv.aspx


3) Find 
<wssawc:InputFormCheckBox
 runat="server"
id="chkSendEmail"
Checked="True"
LabelText="<%$Resources:wss,aclver_SendEmailCheckbox%>"
ToggleChildren=true>


4) By default Checked property is "True". Make it to "False" and save the page.


5) When you add user to group the "Send E-Mail" check box now turn off.


Happy Coding....................

How to develop Custom Tool Part?

What is Tool Part?

When we modified webpart present on SharePoint page, at the time what appears on right hand side is panel. We can specify webpart properties there.
If you want to add custom property to that tool part panel, your webpart should be inherits with “Microsoft.SharePoint.WebpartPages.webpart” instead of “System.Web.UI.WebControls.Webparts.Webpart”.

Let us see example:-
You want to add “Customer name” textbox to tool pane.
Step 1: -
Declare variable for “Customer name” property and add the code within your webpart class.
private string strCustomerName = string.Empty;

[Browsable(false),//Display the property in property pane
Category("CustomToolPart"),//Create a Customer Details category in property pane
DefaultValue(""),//Assign a default value
WebPartStorage(Storage.Personal),//Make available in both personal and shared mode
Personalizable(PersonalizationScope.User),
FriendlyName("Customer Name"),//The caption display in property pane
Description("The name of the customer")]//The tool tip

public string CustomerName
{

get
{
return strCustomerName;
}
set
{
strCustomerName = value;
}
}
If you want to add more properties, you can declare in your webpart class.
Now override one method  which is GetToolParts() on ToolPart method.
public override ToolPart[] GetToolParts()
{
ToolPart[] toolparts = new ToolPart[3];

WebPartToolPart wptp = new WebPartToolPart();

CustomPropertyToolPart custom = new CustomPropertyToolPart();

toolparts[0] = wptp;

toolparts[1] = custom;

toolparts[2] = new {toolpartclass}

return toolparts;
}

In above code “WebPartToolPart” having default properties available in sharepoint and “CustomPropertyToolPart” having customproperty that you want to added.

Ok, let’s develop and create Tool Part class which will have RenderToolPart and ApplyChanges method.

Create a class which inherits from Microsoft.Sharepoint.WebpartPages.ToolPart.

Declare variable which will be name of control render in tool pane.

private string strHTMLinputControlName = "Mycontrol";

protected override void RenderToolPart(HtmlTextWriter output)

{

// Establish a reference to the Web Part.

// CustomWebPart is the web part class name.

{webpartclassname} customWebPart =

(webpartclassname)this.ParentToolPane.SelectedWebPart; 

//Create the input control

output.Write("Enter the customer name: ");

output.Write("<input name= '" + strHTMLinputControlName); 

output.Write("' type='text' value='" + 

SPEncode.HtmlEncode(customWebPart.CustomerName) + "'><br>"); 

}

We have first taken the reference of the webpart class for which we are creating this tool part. So parentToolPane.SelectedWebPart will be the webpart for which we are creating tool Part. Add the following method.

public override void ApplyChanges()
{

// apply property values here

//Get a reference to the web part class

{webpartclassname} cw1 =

(webpartclassname)this.ParentToolPane.SelectedWebPart;

//Pass the custom text to web part custom property

cw1.CustomerName = Page.Request.Form[strHTMLinputControlName];

}

The “ApplyChanges” method which will be called when we press OK. The webpart is now completed with your custom tool pane property. 

Deploy the webpart to your site and add webpart on sharepoint page.
When you edit webpart properties, in tool pane you will find property you have added previously.

Happy coding………………..