Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Tuesday, September 10, 2013

Interview Questions :- .NET,ASP.NET , SQL Server , C#, SharePoint, Javascript, Jquery

Hey All,
   Below are some Questions ( not answers :-) ) that are asked in interviews that I have faced. Hope they prove useful to you for your preparation at some point of time.

 The Questions are mixed of : ASP.NET , SQL Server , .NET Framework , SharePoint , C# , OOPS


  1. What are magic tables in SQL Server 
  2.  How many and what are temp tables in Sql Server ?
  3.  How will you call trigger in Sql Server ?
  4.  How will you call function in Sql Server ?
  5.   There are 2 tables A and B having 3 columns each...What is the output of " Select * from A,B?
  6.   What is the maximum number of Clustered indexes a table can have ?
  7.  when you update a table in SQL Server management studio .., what exactly happens ?
  8.  What is project life cycle?
  9.  What are the differences b/w SQL Server 2008 and SQL Server 2012?
  10.  What is the difference between Site Template and Site Definition?
  11.  What are Generics in C# ? What is the use of it ?
  12.  Protected vs Protected Internal in C# ?
  13.  can we create master page through sharepoint desginer ?
  14.  what is the difference between creating items through sharepoint designer and sharepoint server?
  15.  ASP.NET page life cycle?
  16.  when can we change page's Viewstate ? on which event ?
  17.  can you create site template ? how ?
  18.  what is the prurpose of SPSecurity class in SharePoint ?
  19.  what is Code access security in .NET ?
  20.  There are 2 tables A and B... A has 3 columns , 5 rows ... B has 2 columns , 3 rows ..What will be the output of  a) Select * from A,B b) cross join between 2 tables (how many rows and columns will a cross join between 2 tables return ?)
  21.  What are Cross joins ?
  22. how will update sharepoint list ? write the code.
  23.  what are extension methods in C#?
  24.  what are anonymous methods in c#?
  25.  why multiple inheritance is not possible in C#?
  26. what is a site column in SharePoint?
  27. Difference b/w sandboxed and Farm solution?
  28.  Difference b/w Web Parts and Visual Web Parts.
  29.  how to make a master page in Sharepoint Site?
  30.  abstract class vs interfaces
  31.   Explain Sharepoint Object Model
  32.  What are SPutility and SPMetal in SharePoint ?
  33.  What is .wsdl file in a web service ? 
  34.  how many ways you handle erors in a web page ?
  35.  HttpUtility class vs Http Module
  36.  Can you run JSP pages in IIS ? How ?
  37.  which exception will first occur ?inside BAL , DAL , or UI layers'?
  38.  What does theme in CSS contains ?
  39.  What are views in SQL Server ? can we perform DML in Views?
  40.  User Defined Functions Vs Stored Procedure?
  41.  Difference b/w SQL variable @ and @@
  42.  Difference between Hidden Field vs Viewstate ?
  43.  Boxing and Unboxing difference
  44. What are extension methods and extension classes in C#?
  45.  Inproc vs Outproc in Stored Procedures?
  46.  HTTP module vs HTTP handler
  47.  HTTP get vs HTTP Post?
  48. Abstraction vs Encapsulation
  49.  overloded methods can have different return type?
  50.  static class vs Sealed classes .. why are they used ?
  51.  polymorphism in C#
  52.  types of triggers in SQL SERVER
  53.  Left outer join in SQL SERVER
  54.  What are indexes in SQL SERVER
  55.  What are cursors in SQL Server
  56.  What is the new keyword in Method overriding?
  57.  What are different types of views in SQL Server?
  58.  what is a $ sign in Jquery ?
  59.  How will you enable a website to run only for indian country?
  60.  what are lambda expressions in C#?
  61.  what is difference between array and arraylist ? when to use what and which one is faster?
  62.  what is datareader ? how is it different from dataset?
  63.  What are out, ref parameter in C# method?
  64.  For vs ForEach loop
  65. what is the benefit of putting the .wsp or solution file inside GAC and inside BIN?
  66.  what is RunWithElevatedPrivileges in SharePoint?
  67.  what is the difference between webpart and Visual WebPart?
  68.  what is the difference between Sytem.web.UI.WebControls.Webparts.WebPart vs Microsoft.Sharepoint.WebPart?
  69.  Abstraction Vs Encapsulation
  70.  What is viewstate ? Can you store collections in Viewstate?
  71.  What is the difference between Stored Procedures and User Defined Functions in Sql Server ?
  72.  What is LINQ and advantages of LINQ ?
  73.  I have a collection of strings , Which will be more efficient LINQ or normal for / for each loop?
  74.  What are the ways of storing information into clients computers?
  75.  What are Selectors in Jquery ?
  76.  What are the advantages of Entity Framework?
  77.  Request vs Response Cycle of a Page?
  78. Limitations of sharepoint designer
  79. how will you create master pages and how will you deploy?
  80.  what is a feature ? how will you deploy feature?
  81.  how will you associate one content type to 3 lists ?
  82.  What is caching ? How many types of caching is there?
  83.  What is the difference between caching and session ?
  84.  Generic list vs arraylist vs array in terms of performance and why ?
  85.  why serialization is done and what are the types of serialization?
  86.  What is the difference b/w caching and Session ?
  87. Difference b/w httphandlers and http modules.
  88.  what are the limitations or disadvandtages of Generics
  89.  how to find the 4th highest salary in table?
  90.  .net 2.0 vs .net 4.0 features
  91.  What is garbage collector ?
  92.  garbage collector dispose vs finalize 
  93.  what are table valued functions in SQL Server
  94.  What are shared assemblies
  95.  What is Isnull and collasce operator in SQL Server?
  96.  interface vs abstract class
  97.  return server date in javascript 
  98.  how to increment each salary of all employees with 500 
  99.  how to work with cookies in asp.net 
  100.  javascript function on html control click and asp.net control click

    ALL THE VERY BEST !!!

Monday, July 25, 2011

Http Error : 503. The service is unavailable. SharePoint Central Administration and SharePoint WebApplication


Hi All,
Last Friday , I ran Windows Updates on my Machine. and then ran my SharePoint Site and faced an error "Http Error : 503. The service is unavailable."(See the snapshot below).





I run a headache looking into a solution of this problem, tried restarting all services, sql server and even rebooted my machine serveral times. And after which I found that the Application Pool of all sites was stopped. I started the Application Pool for SharePoint Admin and Other SharePoint WebApplication, and things went fine as usual.

Go to IIS, Application Pools and start the Application Pool one by one of each application.(See the below snapshot)




My Machine Specs: Windows Server 2008 R2, Sql Server 2008 R2, SharePoint Server 2010, Visual Studio 2010

Hope this solution will solve your problem.

Thanks,
Nitin Sharma



Friday, July 22, 2011

Differences Between Sandboxed and Farm Solutions

Hello everybody,
This blog post is for all those guys who are new to Microsoft SharePoint Technologies and want a precise concept of what are Sandboxed solution and Farm Solution.

The MSDN explains it brilliantly......


Below is the content from MSDN :

When you compile a SharePoint solution, it deploys to the SharePoint server and a debugger attaches to debug it. The process used to debug the solution depends on the setting of the Sandboxed Solution property: sandboxed solution or farm solution.


Farm solutions, which are hosted in the IIS worker process (W3WP.exe), run code that can affect the whole farm. When you debug a SharePoint project whose Sandboxed Solution property is set to "farm solution," the system's IIS application pool recycles before SharePoint retracts or deploys the feature so as to release any files locked by the IIS worker process. Only the IIS application pool serving the SharePoint project's site URL is recycled.

Sandboxed solutions, which are hosted in the SharePoint user code solution worker process (SPUCWorkerProcess.exe), run code that can only affect the site collection of the solution. Because sandboxed solutions do not run in the IIS worker process, neither the IIS application pool nor the IIS server must restart. Visual Studio attaches the debugger to the SPUCWorkerProcess process that the SPUserCodeV4 service in SharePoint automatically triggers and controls. It is not necessary for the SPUCWorkerProcess process to recycle to load the latest version of the solution.

With either solution type, Visual Studio also attaches the debugger to the browser to enable client-side script debugging. Visual Studio uses the script debugging engine for this purpose. To enable script debugging, you must change the default browser settings when you are prompted.

Visual Studio attaches the debugger only to the W3WP or SPUCWorkerProcess processes running the current site. Visual Studio also attaches the managed COM Plus and workflow debugging engines.


All about Sanboxed Solution , below is the link from http://technet.microsoft.com

http://technet.microsoft.com/en-us/library/ee721992.aspx

I hope the above links will make you clear differences between Sanboxed and Farm Solution in SharePoint.

Have a great day.!

Thanks,
Nitin Sharma

Thursday, August 12, 2010

System.Windows.Xps.Packaging - Reach Framework => Add reference DLL

Hello Guys,

If you need to use XpsDocument class in your project, you must add reference to System.Windows.Xps.Packaging namespace. It is defined in the ReachFramework.

In order to add reference to ReachFramework, you right click on Add Reference on the project name in Solution Explorer. On the .NET Framework, select ReachFramework and other assemblies from the list and click OK button




Hope you find it useful.
Thanks,
Nitin Sharma
.


Tuesday, August 10, 2010

Database Back up using SQL Query

Hi All,
Today i came through a problem where in i have to take Back up of the SQL server database .
It is a simple query :

BACKUP DATABASE TestDB TO DISK='D:\MyDatabase.bak' with FORMAT


Where
"TESTDB" => Your Database Name
"D:\" => Any local Hard Drive C,D,E,F or any;
"MyDataBase" => Any name by which you want to take Back up.


Thanks,
Nitin Sharma

Friday, March 12, 2010

Upload Word Document using Sharepoint Web Services


All,
Below is the sample code to add a Microsoft Word Document inside the Sharepoint Documen Library's folder.

Say i have a Document Library as CoastGuard and it has four folders : MIS,Aviation,IT and Logistics.So i need to add document in these folders using Sharepoint in built web services.

Below is the Code:

using System;

usingSystem.Collections.Generic;

using System.Configuration;

usingSystem.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Xml;

using System.IO;

using System.Collections;

using Microsoft.SharePoint;

using System.Net;

namespace Signals

{

public partial class Form1:Form

{

public Form1()

{

InitializeComponent();

}

private voidForm1_Load(objectsender,EventArgs e)

{

GetFiles();

GetFoldersList();

}

private void GetFoldersList()

{

wsLists.Lists spList =newSignals.wsLists.Lists();

spList.Credentials = System.Net.CredentialCache.DefaultCredentials;

stringspUrl=ConfigurationSettings.AppSettings["SPFolders"].ToString();

spList.Url ="http://Win08r2/Signals/_vti_bin/Lists.asmx";

XmlNode listnodes = spList.GetListItems("CoastGuard", null, null, null, null, null,null);

foreach (XmlNode nodeinlistnodes)

{

if (node.Name == "rs:data")

{

for (int i = 0; i <>

{

if (node.ChildNodes[i].Name == "z:row")

{

listView1.Items.Add(node.ChildNodes[i].Attributes["ows_LinkFilename"].Value);

}

}

}

}

}

private void GetFiles()

{

string strPath ="..\\..\\Documents";

DirectoryInfo di =newDirectoryInfo(strPath);

FileInfo[] fi = di.GetFiles();

foreach (FileInfo f in fi)

{

listView2.Items.Add(f.Name);

}

}

privatevoidbutton1_Click(objectsender,EventArgs e)

{

wsLists.Lists spList =newSignals.wsLists.Lists();

spList.Credentials = System.Net.CredentialCache.DefaultCredentials;

spList.Url ="http://Win08r2/_vti_bin/Lists.asmx";

listView1.Items[0].Selected =true;

string DocFileName = "";

foreach (ListViewItem linlistView2.SelectedItems)

{

DocFileName = l.Text.ToString();

}

if (DocFileName != "")

{

if(listView1.CheckedItems.Count > 0)

{

for (int i = 0; i <>

{

WebClient WC =newWebClient();

WC.Credentials =CredentialCache.DefaultCredentials;

WC.UploadData("http://Win08r2/signals/CoastGuard/"+ listView1.CheckedItems[i].Text + "/" + DocFileName, "PUT", StreamFile(@"..\\..\\Documents\" + DocFileName));

}

MessageBox.Show("Files moved successfully");

}

else

{

MessageBox.Show("Please Select At Least One Folder");

}

}

else

{

MessageBox.Show("Please Select a File");

}

}

private byte[] StreamFile(stringfilename)

{

FileStream fs =newFileStream(filename,FileMode.Open,FileAccess.Read);

// Create a byte array of file stream length

byte[] ImageData =newbyte[fs.Length];

//Read block of bytes from stream into the byte array

fs.Read(ImageData, 0, System.Convert.ToInt32(fs.Length));

//Close the File Stream

fs.Close();

return ImageData; //return the byte data

}

privatevoidbutton2_Click(objectsender,EventArgs e)

{

foreach (ListViewItem liinlistView1.Items)

{

li.Checked = true;

}

}

privatevoidbutton3_Click(objectsender,EventArgs e)

{

foreach (ListViewItem liinlistView1.Items)

{

li.Checked = false;

}

}

}

}

Here's the Result:

Form1 screenshot.Multiple folders can be selected,but only single file can be selected.


Document uploaded successfully..



Regards,

Nitin Sharma


Tuesday, February 9, 2010

Business Calendar with different event colors- Color coded Calendar in Sharepoint

Hey Everyone,
One requirement occured in our Sharepoint Project was : a Business Calendar with different colors with different events.After googling i came across a wonderful tool which does everything which i need.Moreover it can be customised too....

The tool can be downloaded from here
The source where i found was the author's Blog


It was wondeful..and i got everything that i need for my Sharepoint Project.

Thanks,
Nitin Sharma

Monday, February 8, 2010

Color Picker Tool for MOSS 2007/Sharepoint

Hello,
I found a wonderful Color Picker tool for MOSS 2007.It is awesome tool.You can download it for free from here

Thanks,
Nitin Sharma

Tuesday, January 19, 2010

Fetching Sharepoint User Information dynamically

Hi All,
In sharepoint A user account Information can be fetched out on the fly like Name,Picture,Attachments,About Me etc etc.
In a requirement of my Project i need to find the attachment of the Sharepoint User.

First of all let me know you all that when a user is created Sharepoint internally creates a List called as "User Information List".From this list we can get everything related to SharePoint User.

So here i go with the code snippet:


SPSite objSite = new SPSite(http://YourServerName/YourSiteName);
SPWeb objWeb = objSite.OpenWeb();
SPUser spusr = objWeb.CurrentUser;
SPList list = objWeb.SiteUserInfoList;

SPUserCollection users = objWeb.SiteUsers;
objWeb.AllowUnsafeUpdates = true;
string userId = Request.QueryString["UserId"].ToString();
string userName = "";
foreach (SPUser us in users)
{
if (userId == us.ID.ToString())
{
userName = us.LoginName;
}
}
SPListItem LstItem = list.Items.GetItemById(Convert.ToInt32(userId));
Tempimage.ImageUrl = LstItem.Attachments.UrlPrefix + "/" + LstItem.Attachments[0].ToString() ;



Well the catch here is the Last 2 lines where u give the attachment(here a JPeg image) its source.TempImage is an ASP:Image control.


Similary if you want to update the Profile Picture of a SP User..here you may go like this.

Microsoft.SharePoint.SPList list = web.Lists["User Information List"];
Microsoft.SharePoint.SPUser u = web.SiteUsers["domain\user1"];
Microsoft.SharePoint.SPListItem it = list.Items.GetItemById(u.ID);

it["Picture"] =”http://sharepointApp/sites/wss/photos/abc.jpg”;
it.Update();

Also, you are able to add a custom field to user profile like this:

Microsoft.SharePoint.SPList list = web.Lists["User Information List"];if (!list.Fields.ContainsField("Favorites")){ list.Fields.Add("Favorites", SPFieldType.Text, false); list.Update();}



Do visit for more ideas:
http://www.zimmergren.net/archive/2008/06/25/sharepoints-hidden-user-list-user-information-list.aspx

http://furuknap.blogspot.com/2009/08/sharepoint-user-information-list.html

http://vspug.com/jimyang/2006/12/05/update-wss-3-0-user-profile-programmatically/


Hope it helps.


Thanks,
Nitin Sharma

Wednesday, January 13, 2010

Switch Sharepoint Current User programmatically

Hey All,
If you guys want to switch the SharePoint User time and again in your Application(sharepoint application),then this code will hopefully is for you:


protected void Page_Load(object sender, EventArgs e)
{

SPSite spsite = new SPSite("http://YourServer/YourSite");
SPWeb web = spsite.OpenWeb();
string ObjUsr = "YourServer/YourUserName";
string SITE =
http://YourServer/YourSite;
SwitchUser(web, SITE, ObjUsr);

}



private void SwitchUser(SPWeb web, string siteStr, string user)
{
SPUserToken userToken = web.AllUsers[user].UserToken;
SPSite s = new SPSite(siteStr, userToken);
SPWeb w = s.OpenWeb();
}



The key here is SPUserToken class. When a new site instance is created ,the second parameter is the UserToken which is assigned.

So here : w.CurrentUser.Name is different from web.CurrentUser.Name



Thanks,
Nitin Sharma

Wednesday, December 30, 2009

Creating Sharepoint Site Programmatically

Hello All,
Below code snippet shows how to create a sharepoint site Programmatically.


SPSite oSiteCollection = new SPSite("http://Your Server name/");
SPWeb oWebSite = oSiteCollection.OpenWeb();
oWebSite.AllowUnsafeUpdates = true;
SPWebCollection oSitesCollection = oWebSite.Webs;
SPWeb newWebSite = oSitesCollection.Add("MySPSite", "My SharePoint Site Created Through Code", "This is site created through code.", 1033, "STS#1", true, false);




Thats't it...your dynamic site is now ready..!

For reference of Site Templates refer below:



STS#0
Team Site
STS#1
Blank Site
STS#2
Document Workspace
MPS#0
Basic Meeting Workspace
MPS#1
Blank Meeting Workspace
MPS#2
Decision Meeting Workspace
MPS#3
Social Meeting Workspace
MPS#4
Multipage Meeting Workspace
WIKI#0
Wiki
BLOG#0
Blog



For Locale ID, refer :
http://msdn.microsoft.com/hi-in/goglobal/bb964664(en-us).aspx


Hope it helps...

Thanks,
Nitin Sharma

Programmatically upload a file to a document library in Sharepoint

Hi All,
Below code snippet upload a Doc file(any document) into the document library of a sharepoint site programmatically.

SPSite site = new SPSite("http://YourServerName/YourSite/");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
if (FileUpload2.HasFile)
{
SPFolder myLibrary = web.Folders["YourDocumentLibrary"];
String Filename = Path.GetFileName(FileUpload2.PostedFile.FileName);
FileStream fs = File.OpenRead(FileUpload2.PostedFile.FileName);
SPFile spFile = myLibrary.Files.Add(Filename, fs, true);
myLibrary.Update();
}

Hope it helps you all Sharepoint guys...

Thanks,
Nitin Sharma

Add pictures to the Pictures library in Sharepoint Programmatically





Guys,
This code snippet adds a Picture to the Picture library of the sharepoint site Programmatically.

SPSite Site = new SPSite("http://Your Server Name/YourSite/");
SPWeb web = Site.OpenWeb();
web.AllowUnsafeUpdates = true;
Stream StreamImage = null;
if (FileUpload1.HasFile)
{
StreamImage = FileUpload1.PostedFile.InputStream;
}

SPList pics = web.Lists["Nitin's Picture Library"];
pics.RootFolder.Files.Add(FileUpload1.FileName, StreamImage);



That's it....

Hope it helps...

Thanks,
Nitin Sharma

Tuesday, December 29, 2009

Create Custom Task in MOSS 2007

Guys..Below you can find the script to add custom Task in MOSS 2007 and assigned to a user.


protected void Button1_Click(object sender, EventArgs e)
{
try
{

using (SPSite site = new SPSite(http://YourServerName/YourSite))
{
site.AllowUnsafeUpdates = true;
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList TaskList = web.Lists["MyTasks"];

SPListItem NewTask = TaskList.Lists["MyTasks"].Items.Add();

NewTask["Priority"] = DropDownList2.SelectedValue;

NewTask["Title"] = TextBox1.Text;

NewTask["Description"] = TextBox3.Text;

NewTask["Assigned"] = DropDownList1.SelectedItem.Value;

NewTask.Update();
}
}

}
catch(Exception ex)
{
Response.Write(ex.Message);
}

}




Hope u find it useful...!!!!


Thanks,
Nitin Sharma

Thursday, December 17, 2009

Steps to Install MOSS 2007 in Windows Server 2008

Hi All,
I found this article very great where it shows the steps to install MOSS 2007 in windows server 2008:

Here is the URL : http://mindsharpblogs.com/ben/archive/2007/12/16/3837.aspx

Thanks Ben Curry..!



Hope this article helps to u also...

ba bye....