Code to check whether list exist or not on server


This is a code to Check whether the list exist on the server or not in the Sharepoint.
 

9 Things That Motivate Employees More Than Money

Today I read one nice Post on Linked In. I really like to share it with you all.. It is as below..

By Ilya Pozin |  @ilyaNeverSleeps   | Nov 28, 2011

9 Things That Motivate Employees More Than Money 

The ability to motivate employees is one of the greatest skills an entrepreneur can possess. Two years ago, I realized I didn’t have this skill. So I hired a CEO who did.
Josh had 12 years in the corporate world, which included running a major department at Comcast. I knew he was seasoned, but I was still skeptical at first. We were going through some tough growing pains, and I thought that a lack of cash would make it extremely difficult to improve the company morale.
I was wrong.
With his help and the help of the great team leaders he put in place, Josh not only rebuilt the culture, but also created a passionate, hard-working team that is as committed to growing and improving the company as I am.
Here are nine things I learned from him:
  1. Be generous with praise.  
  2. Get rid of the managers. 
  3. Make your ideas theirs. 
  4. Never criticize or correct. 
  5. Make everyone a leader. 
  6. Take an employee to lunch once a week. 
  7. Give recognition and small rewards. 
  8. Throw company parties.
  9. Share the rewards—and the pain.  
To Read this Points in Detail Please refer to the Actual Post linked below.

Link to the Actual Post

 

A Nice Free Utility to Manage Free Text

While Surfing I found one nice app which help me a lot.

Normally when we are surfing internet for any reasons like to search any code, to search any details for an article or for any reasons.
We like to save some text details. So we copy it and save it in notepad at various locations.

When I was surfing I found one nice free utility through which we can save, store, append the text from anywhere on browser just by pressing a key combination on the keyboard.

You can download it from
 File name: SourceSnap.zip File size:1.53 MB


For more information read the help file in this zip file.

It is really a very useful utility.

Custom Recent Changes Menu in Sharepoint 2010


Here is a code to create custom control in the Sharepoint which can be used in place of Customize
Recently Added Menu.
ASPX Code



Code Behind (.CS File)
Write the following code in the Page Load Event of User Control.




eCode to Change in Wkpstd.aspx file
Take a backup of File <Sharepoint Folder 14 >\TEMPLATE\DocumentTemplates\wkpstd.aspx
Now in original copy
Add dll registration code in the end of header





This will change Recent changes menu in new Custom Recent Changes Menu with 10 Items in list and List Name as a Header Title of the Menu.

Submitted By Nipesh Shah @ 11/2/2011 1:43:32 PM

Collect information from Email using MS Access

This post is to collect information from a number of people easily.
This can be used in offices, surveys, members, family or friends(Personal).
 Using this method we can mail users to fill a form for specific information. the fields of the Access table will sent to specific users vie Email when user replies that mail that information automatically added or updated in the Access table.

Step 1.
Create One table in MS Access (I used 2007 here) with the Fields you want to collect from the user. I create here a table with following fields.



 Step 2.
 Now there are two ways to send this mail.
1. Send the mails to the data of email field in the table. (Used for update table data.)
2. Send the mails to the email addresses in the outlook or custom. (New Information)

We use the second method here.

Right click on the table name and click Collect and Update Data vie E-mail.

This will open an wizard.

Step 3.
Follow the wizard as below...

Click Next ...

In this step select HTML Form. This will generate Html form. In case you and all the members(whom you want to participate in this must have MS Infopath installed to reply your form.
Click Next...

Add all the fields from "Fields in table" to "Fields to Include in e email message" you want to ask to the members.You can exclude fields if required.
Click Next...
Don't forget to Chek the checkbox saying "Automatically process replies and add data to Collect Information" this allows to update the information from receiving mail to your database.
Click Next...

Select first option "Enter the e-mail addresses in Microsoft Outlook" to collect mail id from outlook (for new database) or
select second option "Use the e-mail addresses stored in a field in the database." to collect mail id from database itself.(for data updating purpose)
In our case we select the first option. For second option you need one field in the database with datatype "Hyperlink".

Click Next...
Type the Subject and Custom Message in this form and
Click Next...


This is the final Step Click Create Button to create Emails.

This will create one email message as shown in the image with subject and Custom Message.
Now select the email addresses from your outlook and send the mail to the Members.

Step 4
Step 4 is very nice you have nothing to do in this step.
When your users send reply to this mail their data will automatically update in the database.

Members see this type of email

You need to inform your first time user just to Reply this mail with filled details. As i done above.
When outlook gets the replied mail it will directly update the data in the Access table and not show any Mail in the outlook inbox (no burdon on outlook).
You can see the received information in the Access Database.



If you need any further information please comment on this or mail me....

Nice Layout Creator - MokeUp


Hi, Here is a nice MokeUp creator.
We can create nice layouts from this very easily.
It provide tools to make layouts for website, hand design web template mokeup, Flow Chart, Office etc. 

It's Free Enjoy...
Submitted By Nipesh Shah @ 10/13/2011 8:01:27 PM

Clipboard to Copy Image in C# ,Net

To Copy the Image on the Clipboard the code would be..

First we need to open a Image File using OpenFileDialog.

1) Create an Object of OpenFileDialog , two Button and one PictureBox on the windows form

2) From the first button click event copy the Image to the Clipboard using the code below.

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

Image imageForCopy = Image.FromFile(openFileDialog1.FileName);

Clipboard.SetImage(imageForCopy);

}

3) From the second button click event set the Image from Clipboard to the Picture Box and clear the Clipboard.

pictureBox1.Image = Clipboard.GetImage();

Clipboard.Clear();


Submitted By Nipesh Shah @ 10/5/2011 12:04:22 PM

Using Clipboard to Copy and Paste Text

To Copy the Text on the Clipboard the code would be..

String sourceText = "Some Text";

Clipboard.SetDataObject(sourceText, true);

To Set the Text from the Clipboard the code would be..

string destinationText;

if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))

destinationText = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString();

else

destinationText = "The clipboad does not contain any text";


Submitted By Nipesh Shah @ 10/5/2011 11:46:32 AM

LDAP Authentication - Lightweight Directory Access Protocol

Using the below function we can authenticate the user using LDAP.

LDAP is a Lightweight Directory Access Protocol it is an Internet protocol that email and other programs use to look up information from a server user.

LDAP is an application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network.

LDAP is defined in terms of ASN.1 and transmitted using BER.

using System.DirectoryServices;

public static bool IsLDAPAuthenticate(string userName, string password, string domainName, out string errorMessage)

{

bool IsAuthenticate = false;

errorMessage = string.Empty;

try

{

DirectoryEntry LDAPEntry = new DirectoryEntry("LDAP://" + domainName, userName, password);

object nativeObject = LDAPEntry.NativeObject;

IsAuthenticate = true;

LDAPEntry.Close();

}

catch (Exception exception)

{

errorMessage = String.Format("{0}({1})", exception.Message, domainName);

}

return IsAuthenticate;

}


Submitted By Nipesh Shah @ 10/4/2011 5:50:08 PM

Open CD Rom Drive using C# Code

The below code is used to open CD Rom Drive

//Namespace need to referenced

using System.Text;

using System.Runtime.InteropServices;

//Win32 Api need to call

//Write this as a function

[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi)]

protected static extern int mciSendString(string lpstrCommand,StringBuilder lpstrReturnString,int uReturnLength,IntPtr hwndCallback);

//Call the below function from any of the function where you want to open the CDRom Drive

int ret = mciSendString("Open CD door", null, 0, IntPtr.Zero);


Submitted By Nipesh Shah @ 10/3/2011 10:30:07 AM

Download Document from Sharepoint Library C#

This is the code from which we can allow the user to download the document without giving him any access rights.

This is the condition when want to give one functionality for downloading in asp.net site.

Function 1. In first function we need to pass filename, document Id and serverpath.

server path is a temperory path we need to copy file on server until user download it.

public string DownloadDocument(string FileName, int documentId, string serverpath)

{

ContractDataAccess cda = new ContractDataAccess();

Stream file;

try

{

{

file = cda.GetDocumentById(documentId);

FileStream fsDocFile;

StreamReader srWebSrc = new StreamReader(file);

string filepath = serverpath + FileName;

if(System.IO.File.Exists(filepath))

fsDocFile = System.IO.File.Open(filepath, FileMode.Truncate);

else

fsDocFile = System.IO.File.Open(filepath, FileMode.Create);

file.CopyTo(fsDocFile);

srWebSrc.Close();

fsDocFile.Close();

return filepath;

}

}

catch (Exception ex)

{

throw ex;

}

}

we need to pass sharepoint ID of the document to the function.

public Stream GetDocumentById(int documentId)

{

//The four values below are retrieved from config file. They gives the values for authenticated user, sharepoint website path, password, and server name. This can be used on same server only.

string user = ConfigurationManager.AppSettings["User"].ToString();

string webUrl = ConfigurationManager.AppSettings["WebUrl"].ToString();

string pass = ConfigurationManager.AppSettings["Password"].ToString();

string server = ConfigurationManager.AppSettings["Server"].ToString();

NetworkCredential credentials = new NetworkCredential(user, pass, server);

ListItem item = GetdocumentFromId(documentId);

if (item != null)

{

using (ClientContext clientContext = new ClientContext(webUrl))

{

clientContext.Credentials = credentials;

FileInformation fInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, item["FileRef"].ToString());

return fInfo.Stream;

}

}

return null;

}

public ListItem GetdocumentFromId(Int32 documentId)

{

Contract contract = null;

List resultlist = null;

ListItem contractItem = null;

try

{

//The four values below are retrieved from config file. They gives the values for authenticated user, sharepoint website path, password, and server name. This can be used on same server only.

string webUrl = ConfigurationManager.AppSettings["WebUrl"].ToString();

string user = ConfigurationManager.AppSettings["User"].ToString();

string pass = ConfigurationManager.AppSettings["Password"].ToString();

string server = ConfigurationManager.AppSettings["Server"].ToString();

NetworkCredential credentials = new NetworkCredential(user, pass, server);

using (var clientContext = new ClientContext(webUrl))

{

clientContext.Credentials = credentials;

resultlist = clientContext.Web.Lists.GetByTitle("<ListName>");

contractItem = resultlist.GetItemById(documentId);

clientContext.Load(resultlist);

clientContext.Load(contractItem);

clientContext.ExecuteQuery();

}

contract = new Contract();

}

catch (Exception exception)

{

Console.WriteLine(exception.Message);

}

return contractItem;

}


Submitted By Nipesh Shah @ 9/26/2011 7:51:10 PM

Javascript Code to hide html object on webpage

Javascript code to hide any element for hiding the object.

This can also be good for Sharepoint.

<script type="text/javascript">

document.getElementById('ClientId of the Object').style.display="none";

</script>


Submitted By Nipesh Shah @ 9/22/2011 11:29:34 AM

Create Sequential Workflows for SharePoint 2010 in Visual Studio 2010?

Code to find Days between two dates in C#

Code to calculate no of days between two dates

DateTime date1 = new DateTime(1986, 8, 10);

DateTime date2 = new DateTime(2011, 3, 12);

TimeSpan ts = date2 - date1;

int days = ts.TotalDays;


Submitted By Nipesh Shah @ 9/20/2011 12:39:35 PM

Add Skype Button on your blog or website

Skype is widely used communication s/w.

Skype is providing Chat button for your website or blog.

You need to just fill the simple form on http://www.skype.com/intl/en/tell-a-friend/wizard/ and it will generate one html.

Copy this html and paste it where ever you want.(On blog or on Website).

It helps people to directly chat with you.

Nipesh Shah
Submitted By Nipesh Shah @ 9/20/2011 12:30:37 PM

Show Content per user in sharepoint 2010

In sharepoint there is a Security control using which we can hide or show the page content according to the permissions of the user.

We can use SPSecurityTrimmedControl for doing so. Using this control is very easy. You need to add this tag before the code you want to hide.

Example :

<Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ManageLists">

Put your code, sharepoint control etc here

</SharePoint:SPSecurityTrimmedControl>

Permissions are the criteria from which we can Manage the security.

List of various permissions is as under.

EmptyMask - Has no permissions on the Web site. Not available through the user interface.

ViewListItems - View items in lists, documents in document libraries, and view Web discussion comments.

AddListItems - Add items to lists, add documents to document libraries, and add Web discussion comments.

EditListItems - Edit items in lists, edit documents in document libraries, edit Web discussion comments in documents, and customize Web Part Pages in document libraries.

DeleteListItems - Delete items from a list, documents from a document library, and Web discussion comments in documents.

ApproveItems - Approve a minor version of a list item or document.

OpenItems - View the source of documents with server-side file handlers.

ViewVersions - View past versions of a list item or document.

DeleteVersions - Delete past versions of a list item or document.

CancelCheckout - Discard or check in a document which is checked out to another user.

ManagePersonalViews - Create, change, and delete personal views of lists.

ManageLists - Create and delete lists, add or remove columns in a list, and add or remove public views of a list.

ViewFormPages - View forms, views, and application pages, and enumerate lists.

Open - Allow users to open a Web site, list, or folder to access items inside that container.

ViewPages - View pages in a Web site.

AddAndCustomizePages - Add, change, or delete HTML pages or Web Part Pages, and edit the Web site using a SharePoint Foundation-compatible editor.

ApplyThemeAndBorder - Apply a theme or borders to the entire Web site.

ApplyStyleSheets - Apply a style sheet (.css file) to the Web site.

ViewUsageData - View reports on Web site usage.

CreateSSCSite - Create a Web site using Self-Service Site Creation.

ManageSubwebs - Create subsites such as team sites, Meeting Workspace sites, and Document Workspace sites.

CreateGroups - Create a group of users that can be used anywhere within the site collection.

ManagePermissions - Create and change permission levels on the Web site and assign permissions to users and groups.

BrowseDirectories - Enumerate files and folders in a Web site using Microsoft Office SharePoint Designer 2007 and WebDAV interfaces.

BrowseUserInfo - View information about users of the Web site.

AddDelPrivateWebParts - Add or remove personal Web Parts on a Web Part Page.

UpdatePersonalWebParts - Update Web Parts to display personalized information.

ManageWeb - Grant the ability to perform all administration tasks for the Web site as well as manage content. Activate, deactivate, or edit properties of Web site scoped Features through the object model or through the user interface (UI). When granted on the root Web site of a site collection, activate, deactivate, or edit properties of site collection scoped Features through the object model. To browse to the Site Collection Features page and activate or deactivate site collection scoped Features through the UI, you must be a site collection administrator.

UseClientIntegration - Use features that launch client applications; otherwise, users must work on documents locally and upload changes.

UseRemoteAPIs - Use SOAP, WebDAV, or Microsoft Office SharePoint Designer 2007 interfaces to access the Web site.

ManageAlerts - Manage alerts for all users of the Web site.

CreateAlerts - Create e-mail alerts.

EditMyUserInfo - Allows a user to change his or her user information, such as adding a picture.

EnumeratePermissions - Enumerate permissions on the Web site, list, folder, document, or list item.

FullMask - Has all permissions on the Web site. Not available through the user interface.


Submitted By Nipesh Shah @ 9/20/2011 12:17:49 PM

Generate XML from directory Structure

The given code snippets is used to generate the Directory Structure to an XML File.

This XML File can be used in various ways, for appending in treeview, store as a file, export in string format etc.

public String getXMLFromDirectoryStructure()

{

try

{

string ProjectFolder = "Project"; //absolute path for project

string appPath = "C:\Project"; //absolute path for project

string bodyFile = Path.Combine(appPath, @"Snippets\");

XmlDocument doc = new XmlDocument();

doc.LoadXml("< $ProjectFolder$ name=\"$ProjectFolder$\" type=\"DIR\">" + "</$ProjectFolder$>");

DirectoryInfo mainDir = new DirectoryInfo(bodyFile);

foreach (DirectoryInfo dir in mainDir.GetDirectories())

{

XmlElement elem = GetData(dir.FullName, doc);

doc.DocumentElement.AppendChild(elem);

}

StringWriter sw = new StringWriter();

XmlTextWriter tx = new XmlTextWriter(sw);

doc.WriteTo(tx);

doc.Save(bodyFile + "\\" + "Path.xml");

return sw.ToString();

}

catch (Exception)

{

}

return "";

}

private static XmlElement GetData(string dirName, XmlDocument doc)

{

//create a new node for this directory

XmlElement elem = doc.CreateElement("dir");

DirectoryInfo di = new DirectoryInfo(dirName);

elem.SetAttribute("name", di.Name);

elem.SetAttribute("type", "DIR");

foreach (DirectoryInfo dinf in di.GetDirectories())

{

//Recursively call the directory with all underlying dirs and files

XmlElement elemDir = GetData(dirName + "\\" + dinf.Name, doc);

if (dinf.GetDirectories().Count() + dinf.GetFiles().Count() == 0)

{

elemDir.InnerText = "";

}

elem.AppendChild(elemDir);

}

return elem;

}


Submitted By Nipesh Shah @ 9/19/2011 4:56:27 PM

Jquery Server Control For ASP.NET

Jquery Server Controls From DotNetAge provides server side events.

Download DLLs from http://dj.codeplex.com/

Below is example for Accordion

<%@ Register Assembly="DNA.UI.JQuery" Namespace="DNA.UI.JQuery" TagPrefix="DotNetAge" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

<link href="Jquery/jquery-ui-1.8.13.custom.css" rel="stylesheet" type="text/css" />

<link href="Jquery/dna.ui.css" rel="stylesheet" type="text/css" />

</asp:Content>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<asp:LinkButton ID="lnkPopUp" runat="server" OnClientClick="return false;">Open PopUp Window</asp:LinkButton>

<DotNetAge:Accordion ID="Accordion1" runat="server" Navigation="true" AllowCollapseAllSections="true"

CollapseAnimation="EaseSlide" CssClass="ui-accordion-header" ContentCssClass="ui-accordion-content"

Width="200px">

<Views>

<DotNetAge:NavView ID="NavView1" runat="server" Text="Dashboard" NavigateUrl="About.aspx"

OnClientClick="">

<Items>

<DotNetAge:NavItem Text="Go to Dashboard" NavigateUrl="About.aspx" />

</Items>

</DotNetAge:NavView>

<DotNetAge:NavView ID="NavView2" runat="server" Text="Title 2">

<Items>

<DotNetAge:NavItem Text="All Contacts" NavigateUrl="About.aspx" />

<DotNetAge:NavItem Text="Persional" />

</Items>

</DotNetAge:NavView>

<DotNetAge:NavView ID="NavView3" runat="server" Text="Title 3">

<Items>

<DotNetAge:NavItem Text="All Contacts" />

<DotNetAge:NavItem Text="Persional" />

</Items>

</DotNetAge:NavView>

<DotNetAge:NavView ID="NavView4" runat="server" Text="Title 4">

<Items>

<DotNetAge:NavItem Text="All Contacts" />

<DotNetAge:NavItem Text="Persional" />

</Items>

</DotNetAge:NavView>

</Views>

</DotNetAge:Accordion>

</asp:Content>

for server side binding...

using DNA.UI.JQuery;

protected void Page_Load(object sender, EventArgs e)

{

DNA.UI.JQuery.View v1 = new DNA.UI.JQuery.View();

v1.Text = "My Mail"; //Title for accordion

NavView n1 = new NavView();

n1.ID = "nav1";

n1.Text = "Inbox"; // sub item for accordion

v1.Controls.Add(n1);

Accordion1.Views.Add(v1);

}

Visit http://www.dotnetage.com for Documentation

-

Manthan Vyas
Submitted By manthan vyas @ 9/19/2011 4:25:21 PM

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...