Tuesday, July 7, 2009

Customize Edit Page and Redirect page after update using java script

1. In Sharepoint Designer take your EditForm.aspx and copy it.
2. Rename it
3. Open this new form and click on the PlaceHolderMain (leave your ListFormWebPart on the page)
4. In the ListFormWebPart scroll down the properties in the xml which describes the webpart and change to false. For some reason the form will not work unless you leave the original on the page.
4. Click on Insert->Sharepoint Controls->Custom List Form
5. Choose the appropriate List and select Edit Form
6. Sharepoint generates the form for you.

To customize the save button, find the following control on the page Sharepoint:SaveButton

1. Delete the SaveButton
2. Add

input type="button" value="Save" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={Thanks.aspx}')}"

instead
3. This button allows the form to be saved and redirects to back to that page.

Friday, July 3, 2009

Delete Title Column in custom list sharepoint

Title column in custom list could be confusing in sharepoint. When you create any new custom list, Tital column is default column in list. You can't delete it but rename column name.

There is no way to Hide or Delete “Title” Column from List Settings User Interface. You can hide it by deselecting this column in your View but then you cannot edit the item as you wouldn’t have any Column linked to edit menu.

he only way to hide the “Title” Column is by writing a Custom List Definition, remember every Custom List MUST have this column as this is included in the Global ONET.xml (for Type “0″ List).

<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" ReadOnly="TRUE" Required="FALSE" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title">
</Field>
<Field ID="{82642ec8-ef9b-478f-acf9-31f7d45fbc31}" Name="LinkTitle" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitle">
</Field>
<Field ID="{bc91a437-52e7-49e1-8c4e-4698904b2b6d}" Name="LinkTitleNoMenu" Hidden="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="LinkTitleNoMenu">
</Field>

Monday, June 29, 2009

World Clock Webpart


Today, I have released world clock webpart on codeplex.
You can download it from below link.
http://worldclock.codeplex.com/

After download, read document and installed it on MOSS Server.

It looks like below.








Friday, June 26, 2009

Free - SharePoint Text Size Zoom Feature

Sharepoint Text Size zoom functionality is useful in organization for low resolution projector.

Here i have mentions step to integrate with sharepoint site.
(1) Open Sharepoint Site in sharepoint Designer .
(2) Open _catalogs folder and create new folder "JS"
(3) Add new javascript into that rename as TextSize.js
(4)Open Javascript and add below code into js and save it.


function FontSizeChange_SetAllDocumentFontSize(size)
{
FontSizeChange_ChangeAllElements(document, size);

for(var i = 0; i < document.frames.length; i++)
{
FontSizeChange_ChangeAllElements(document.frames[i].document, size)
}
}

function FontSizeChange_RestoreDefault()
{


FontSizeChange_ReloadWindow(true);
}

function FontSizeChange_ReloadWindow(refresh)
{
if(refresh)
{
var url = window.location.href;
if(url.indexOf("#") == url.length - 1)
{
window.location.href = url.substring(0, url.length - 1)
}
else
{
window.location.href = url;
}
}
else
{
window.location.reload();
}
}
function FontSizeChange_ChangeAllElements(doc, size)
{
FontSizeChange_SetFontSizeByTagName(doc, "div", size);
FontSizeChange_SetFontSizeByTagName(doc, "span", size);
FontSizeChange_SetFontSizeByTagName(doc, "input", size);
FontSizeChange_SetFontSizeByTagName(doc, "a", size);
FontSizeChange_SetFontSizeByTagName(doc, "td", size);
FontSizeChange_SetFontSizeByTagName(doc, "th", size);
FontSizeChange_SetFontSizeByTagName(doc, "select", size);
FontSizeChange_SetFontSizeByTagName(doc, "font", size);
FontSizeChange_SetFontSizeByTagName(doc, "textarea", size);
FontSizeChange_SetFontSizeByTagName(doc, "IE:MENUITEM", size);
}

function FontSizeChange_Increase()
{
var font=document.getElementById('txtFont').value;
if(font <20)
{
document.getElementById('txtFont').value=parseInt(document.getElementById('txtFont').value) + 1;
}

var fontSize = font.toString() + "px";
FontSizeChange_SetFontSize(fontSize);


}

function FontSizeChange_SetFontSize(size)
{
FontSizeChange_SetAllDocumentFontSize(size);

}

function FontSizeChange_Decrease()
{
var font=document.getElementById('txtFont').value;
if(font > 8)
{
document.getElementById('txtFont').value=parseInt(document.getElementById('txtFont').value) - 1;
}

var fontSize = font.toString() + "px";
FontSizeChange_SetFontSize(fontSize);

}


function FontSizeChange_SetFontSizeByTagName(doc, tag, size)
{
var elements = doc.getElementsByTagName(tag);
for(var i = 0; i < elements.length; i ++)
{
elements[i].style.fontSize = size;
}
}


(5) Open Master page and add below script.

<script language="javascript" src="../JS/TextSize.js" type="text/javascript"></script>

(6) Also add below code into master page top corner.

<a title="Decrease Text Size" href="javascript:FontSizeChange_Decrease();"><asp:image runat="server" ID="imgdecrease" ImageUrl="_layouts/IMAGES/_size_small.gif" ></asp:image></a>

<a title="Default Text Size" href="javascript:FontSizeChange_RestoreDefault()"><asp:Image ID="imgdefault" runat="server" ImageUrl="_layouts/IMAGES/_size_medium.gif"></asp:Image></a>

<a title="Increase Text Size" href="javascript:FontSizeChange_Increase();"><asp:Image ID="imgincrease" runat="server" ImageUrl="_layouts/IMAGES/font_size_large.gif" ></asp:Image></a>

<input id="txtfont" type="hidden" value="12" >


Add image as per your requirement.

After complete this procedure, feature is look like below.






Cheers it and enjoy it.

Wednesday, June 17, 2009

Hide Sharepoint Site Action for non authentic user group

Sharepoint Site Action hiding is easy for non authenticate user. It is possible using sharepoint designer and after that only administrator's view Site Action button in sharepoint web application.

Open Sharepoint Designer and find SiteAction control in master page. Add
SPSecurityTrimmedControl before that.


<SharePoint:SPSecurityTrimmedControl runat="server" PermissionsString="ManageWeb" >


<SharePoint:SiteActions runat="server" AccessKey="<%$Resources:wss,tb_SiteActions_AK%>" id="SiteActionsMenuMain" ..........>
............
</SharePoint:SiteActions>

</SharePoint:SPSecurityTrimmedControl>

Tuesday, June 16, 2009

SharePoint DateTime Control Validation

<wssawc:DateTimeControl ID="dteDemo" runat="server" DateOnly="true" ></wssawc:DateTimeControl>


<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please select activity date." ControlToValidate="dteDemo$dteDemoDate" ValidationGroup="Activity" Display="None"></asp:RequiredFieldValidator>

<asp:CompareValidator id="vdate" Display="None" runat="server" ControlToValidate="dteDemo$dteDemoDate" Type="date" Operator="dataTypeCheck" ErrorMessage="Please enter an valid date." vallidationGroup="Activity"></asp:CompareValidator>

Automatic take sharepoint site backup using batch file and scheduler

It is not possible to schedule sharepoint backup from sharepoint central admin site.
Below is process to take backup using batch file and after running schedule on specific time.

1. Open notepad and paste below code.

@echo off

@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"

cd c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN

@echo off

md "%DATE:/=_%"

stsadm -o backup -url "http://localhost:8080" -filename "E:\MOSS_Backup\%DATE:/=_%.bak"

echo completed

2. Save it as AutoBackup.bat (Change your site name )

Set Task schedular for this batch file and take backup on schedule time.