Wednesday, November 17, 2010

Avoiding Flickering in jQuery

Avoiding Flickering in jQuery on moss application
Refer
http://avinash-moss-expert.blogspot.com/2010/11/flickering-issue-with-jquery-in.html

Remove page flicker in sharepoint

refer
http://avinash-moss-expert.blogspot.com/2010/11/flickering-issue-with-jquery-in.html

flickering issue with jquery in sharepoint

Hi,

I had flickering issue on sharepoint site when i try to use jQuery. I search lots but none of solution works for me.Few solution are there on some blogs like:-
http://weblogs.asp.net/wesleybakker/archive/2008/12/29/Eliminate-page-flicker-in-SharePoint.aspx
http://weblogs.asp.net/wesleybakker/
http://www.alligatortags.com/alligatortags-12-29-2008.html
http://www.developerit.com/en/search/page-138/get-the-title
http://www.psearch.info/s/irritating-flicker-postbacks-server
as per these above blogs below code solve issue
<meta http-equiv="Page-Exit" content="blendTrans(Duration=0.0)" />
but all these does not solve my issue. Finaly i got solution which is mentioned below:-

In sharepoint we start using jQuery or JavaScript like below:-
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("RoundCorner");
function RoundCorner() {
// all js code will come here
$('div.graybackground').corner("round");
// all js code will come here
}
</script>

I add two lines extra in script and replace function as below:-
<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("RoundCorner");
function RoundCorner() {
$('body').css('display', 'none');
// all js code will come here
$('div.graybackground').corner("round");
// all js code will come here
$('body').css('display', 'block');
}
</script>

 
Thanks!
Avinash

Wednesday, November 10, 2010

custom pagination in gridview

If you want to implement custom pagination having "Next" and "Prev" button in gridview then you have following options:-

http://www.codeproject.com/KB/aspnet/CustomPagingForGridview.aspx
http://msdn.microsoft.com/en-us/library/aa479347.aspx
http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

But i have got one more good solution which works well for me. See below:-

GridView1.PagerSettings.Mode = PagerButtons.NumericFirstLast;
GridView1.PagerSettings.NextPageText = ">";
GridView1.PagerSettings.PreviousPageText = "<"; GridView1.PagerSettings.LastPageText = ">>";
GridView1.PagerSettings.FirstPageText = "<<";

GridView1.RowDataBound+=new GridViewRowEventHandler(GridView1_RowDataBound); 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
{
 if (e.Row.RowType == DataControlRowType.Pager) 
{ Table pagerTable = (Table)e.Row.Cells[0].Controls[0]; 
TableRow pagerRow = pagerTable.Rows[0]; 
PagerSettings pagerSettings = ((GridView)sender).PagerSettings; 
int cellsCount = pagerRow.Cells.Count; 
if (pagerSettings.Mode == PagerButtons.Numeric || pagerSettings.Mode == PagerButtons.NumericFirstLast) {
 int prevButtonIndex = pagerSettings.Mode==PagerButtons.Numeric ? 0 : 1; 
int nextButtonIndex = pagerSettings.Mode==PagerButtons.Numeric ? cellsCount-1 : cellsCount-2; 
if (prevButtonIndex < cellsCount) 
{ //check whether previous button exists LinkButton btnPrev = pagerRow.Cells[prevButtonIndex].Controls[0] as LinkButton; if (btnPrev != null && btnPrev.Text.IndexOf("...") != -1) btnPrev.Text = pagerSettings.PreviousPageText; 

if (nextButtonIndex > 0 && nextButtonIndex < cellsCount)
{
//check whether next button exists
LinkButton btnNext = pagerRow.Cells[nextButtonIndex].Controls[0] as LinkButton;
if (btnNext != null && btnNext.Text.IndexOf("...") != -1)
btnNext.Text = pagerSettings.NextPageText;
}
}
}
}

Thanks!
Avinash

Thursday, October 21, 2010

How to control "Access Denied" page

The SPUtility.HandleAccessDenied method provides the functionality to redirect users to the standard "Access Denied Page" pragmatically, thus asking them to re-logon. One of the scenarios of such usage is the public sites, where access to the standard SharePoint specific pages still exists and you want to block those pages

However, you can handle access denied exception via SPSecurity.CatchAccessDeniedException = true (source)

How to avoid Access denied page

Access deined exception is handled by sharepoint platform and user will be redirected to _layouts/AccessDenied.aspx page if user doesnt have permission to perform that task. This might casue usability problem in some cases. You can handle access denied exception in your code by setting CatchAccessDeniedException value to true.
Following code snippet shows how to handle access denied exception:

bool catchException = SPSecurity.CatchAccessDeniedException;
SPSecurity.CatchAccessDeniedException = false;
try
{
//updating list item
SPList list = SPcontext.Current.Web.List["TestList"];
SPListItem item = list.Items[0];
item["title"] = "Some value";
//If user doesnt have permission, exception will be thrown
//If value of CatchAccessDeniedException is true, then user will be
//redirected to AccessDenied.aspx page
item.Update();
}
cach(Exception ex)
{
//Your custom error message can be shown here
}
finally
{
//reset the flag to original value
SPSecurity.CatchAccessDeniedException = catchException;
}

Reference: sridharu blog.

Thanks!
Avinash

Wednesday, October 20, 2010

Custom Content Query Web Part

When we need to add some custom property into OOB CQWP then we have to create custom CQWP.
As well as when we need redeploy CQWP then also we need to use custom content query web part.

Please view below code to create custom content query web part:-

1 point: We need to create a custom class whcih extend OOB content query web part class

public class CustomPortalContentQuery : ContentByQueryWebPart
{
public override ToolPart[] GetToolParts()
{
List toolPart = new List(base.GetToolParts());
toolPart.Insert(0, new CustomPortalToolPart());
return toolPart.ToArray();
}
protected override void OnInit(EventArgs e)
{
FixListGuid(); // this to fix list guid if you are redeploying cqwp to other site
this.ItemXslLink = this.ServerRelativeItemXslLink;
this.MainXslLink = this.ServerRelativeMainXslLink;
base.OnInit(e);

}
protected override void CreateChildControls()
{
base.CreateChildControls();
}

private void FixListGuid(){
try
{
if (!string.IsNullOrEmpty(base.WebUrl) && !string.IsNullOrEmpty(base.ListName))
{
using (SPWeb web = SPContext.Current.Site.OpenWeb(base.WebUrl, true))
{base.ListGuid = web.Lists[base.ListName].ID.ToString();
}
}
}
catch (Exception ex){}
}
}
}

2 point: We need to create a custom class for tool pane.
internal class CountryPortalToolPart : Microsoft.SharePoint.WebPartPages.ToolPart
{
CustomPortalContentQuery webpart;
TextBox itemXslLink;
Panel toolPanel;
Table toolPanelTable;
public CountryPortalToolPart()
{
this.Title = "Custom Settings";
}
protected override void CreateChildControls()
{
webpart = this.WebPartToEdit as CustomPortalContentQuery;
toolPanel = new Panel();toolPanel.CssClass = "ms-ToolPartSpacing";
toolPanel.Controls.Add(GetToolPanel());
this.Controls.Add(toolPanel);
base.CreateChildControls();
}

public override void ApplyChanges()
{try
{
webpart.ItemXslLink = itemXslLink.Text;
}

catch { }

base.ApplyChanges();}
private Control GetToolPanel()
{
toolPanelTable = new Table();
toolPanelTable.CellPadding = 0;
toolPanelTable.CellSpacing = 0;
toolPanelTable.Style["border-collapse"] = "collapse";
toolPanelTable.Attributes.Add("width", "100%");
toolPanelTable.Rows.Add(GetItemXslLinkRow());
return toolPanelTable;
}

private TableRow GetItemXslLinkRow()
{

TableRow row = new TableRow();
TableCell cell = new TableCell();

cell.Controls.Add(new LiteralControl("
Item XSL Link:
"));
cell.Controls.Add(new LiteralControl("
"));


itemXslLink = new TextBox();
if (string.IsNullOrEmpty(webpart.ItemXslLink))
{
itemXslLink.Text = this.webpart.ServerRelativeItemXslLink;
}
else
itemXslLink.Text = this.webpart.ItemXslLink;
cell.Controls.Add(itemXslLink);
cell.Controls.Add(new LiteralControl("
"));
row.Cells.Add(cell);
return row;
}
}


Hope it helps you.

Thanks!
Aviansh

import content query web part to other site

While import exiting CQWP from one site to other site, gives an issue of List GUID. It does not work since it point to old site list guid.

I got solution for this. First of course we need to create Custom CQWP whcih extent OOB CQWP. then i wrote a function to fix listGUID issue.
please refer my article

Making the content query web part deployable

Thanks!
Avinash

Making the content query web part deployable

My biggest issue with the CQWP? its not deployable when connected to a specific list in a specific site.
If you configure a CQWP web part to connect to a list in a site, the web part saves the ID (GUID) of the list - and if you want to deploy the web part as part of a feature or onet.xml so that the web part gets added every time a user creates a site, it will fail - because the ID of the list changes every time you create a new site.
My solution? override the web part and implement the following functions:
private void FixListGuid()
{
try
{

if (!string.IsNullOrEmpty(base.WebUrl) && !string.IsNullOrEmpty(base.ListName))
{
using (SPWeb web = SPContext.Current.Site.OpenWeb(base.WebUrl, true))
{
base.ListGuid = web.Lists[base.ListName].ID.ToString();
}
}
}
catch (Exception ex)
{
SPZetaContext.GetContext(HttpContext.Current).Log.Warn("Unable to resolve SPList '" + this.ListName + "'", ex);
}
}
protected override void OnLoad(EventArgs e)
{
FixListGuid ();
base.OnLoad(e);
}
}

This code works for me..

How to create custom Content Query Web Part


Thanks!
Avinash

Friday, October 8, 2010

This page contains content or formatting that is not valid. You can find more information in the affected sections

You get this error when you are trying to update a SharePoint webpart tool part or something like that and you click on 'Publish' page button. This only happens if you have any Validation Controls on your webpart.

Resolution: As you have validation controls on your webpart UI and you are not filling in anything, it is not letting your page to postback and you need to disable rendering the webpart while you are modifying the toolpart. You can do that by writing down code as below in your 'CreateChildControls method of webpart

protected override void CreateChildControls()
{ 

WebPartManager wp = WebPartManager.GetCurrentWebPartManager(this.Page); 
if (wp.DisplayMode == WebPartManager.BrowseDisplayMode)
{
// add your validator control
} 
else
{
// dont add your validator control
}

base.CreateChildControls(); 

}

Thanks & Regards,
Avinash Dad

Monday, October 4, 2010

Document Icon in CQWP

You can find solution on some blogs like:-
http://edinkapic.blogspot.com/2007/09/document-icon-in-cqwp.html

But I got very short solution which is mentioned below:-

First, we should add the DocIcon in the CommonViewFields property (export the CQWP, edit the .webpart file) as follows:

<property name="CommonViewFields" type="string"">DocIcon, Lookup;</property">

Then, you can use following tempalte to get icon:-

<xsl:template name="RecentDcoument" match="Row[@Style='RecentDcoument']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<div id="linkitem" class="item" style="vertical-align:middle;">
<div style="float:left;">
<IMG BORDER="0" ALT="{@FileLeafRef}" title="{@FileLeafRef}" SRC="/_layouts/images/{ddwrt:MapToIcon(string(@DocIcon),string(@DocIcon))}" />
</div>
<div>
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" target="{$LinkTarget}" title="{@LinkToolTip}" style="padding-left:5px;">
<xsl:value-of select="ddwrt:UrlBaseName(string($SafeLinkUrl))" />
</a>
</div>
</div>
</xsl:template>

Wednesday, August 11, 2010

Export Webpart programmatically using SPLimitedWebpartManager

Export Webpart programmatically

==========================================================================

private void ExportWebpart(SPLimitedWebPartManager wpm, string strFilePath)
{

XmlTextWriter writer;
foreach (var webPartOnPage in wpm.WebParts)
{
try
{
System.Web.UI.WebControls.WebParts.WebPart webPartObj = (System.Web.UI.WebControls.WebParts.WebPart)(webPartOnPage);

if (!Directory.Exists(strFolderPath))
{
Directory.CreateDirectory(strFolderPath);
}
//Store below detail into xml since some web part does not export (eg: filter text web part)
// So while import we can use below detail and addwebpart using assembly name.

// RemoveSpecialCharacters(webPartObj.Title);
// wpm.GetZoneID(webPartObj);
// webPartObj.ZoneIndex;
// webPartObj.GetType().AssemblyQualifiedName;

writer = new XmlTextWriter(strFilePath, Encoding.UTF8);
wpm.ExportWebPart(webPartObj, writer);

writer.Flush();
writer.Close();
}
catch {}

}

}

==========================================================================

This above function can be use for following points:-

SPLimitedWebpartManager.ExportWebPart(Webpart, XmlWriter) throws XmlException
like below:-
The prefix '' cannot be redefined from '' to 'http://schemas.microsoft.com/WebPart/v3' within the same start element tag.
Then change xmlwriter to xmltextwriter. Same you can see in above function.

or

SPLimitedWebpartManager.ExportWebPart

The biggest issue:-
============================

SPLimitedWebpartManager.ExportWebPart(Webpart, XmlWriter) throws XmlException
XmlException when you use Text Filter Web Part (SPSlicerTextWebPart)
As per understanding, There is no solution for this. So I have other work around for this.

Why we are exporting? Since we might want import to some other site.

So what we can do, while export, store webpart detail in xml file. And while import creates 2 function as mentioned below:-

1. this is for those which have .webpart file

for this use my function "AddWebPartToPage" which u can refer from other article.

2. This is: for those which does not have webpart file means it couldn’t export. Then use following function to addwebpart

private void AddWebPartToPageUsingAssembly(string strWebPartName, SPWeb oWeb, string strZoneId, int ZoneIndex, SiteWebPart webpartSetting)
{
//here webPartSetting object contains the properties of those webpart which couldn’t export
// you can get these object using the xml which you have exported while webpart export.

SPFile file = null;
SPLimitedWebPartManager manager = null;

try
{
if (webpartSetting != null)
{
string strType = webpartSetting.Settings.AssemblyType;
Type type = Type.GetType(strType);
Assembly assemblyType = type.Assembly;
System.Web.UI.WebControls.WebParts.WebPart webPartObj = (System.Web.UI.WebControls.WebParts.WebPart)assemblyType.CreateInstance(type.FullName);
webPartObj.ChromeType = PartChromeType.None;
webPartObj.Title = webpartSetting.Settings.Title;

if (String.Compare(webPartObj.GetType().Name, "SPSlicerTextWebPart", true) == 0)
{
(((Microsoft.SharePoint.Portal.WebControls.SPSlicerBaseWebPart)(webPartObj))).FilterName = webpartSetting.Settings.FilterName;
}
file = oWeb.GetFile(strPageUrl);

if (file.CheckOutStatus == SPFile.SPCheckOutStatus.None)
{
file.CheckOut();
manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
manager.AddWebPart(webPartObj, strZoneId, ZoneIndex);
oWeb.Update();
}
}

}
catch (Exception ex)
{
// Exception details
}
finally
{
if (manager != null)
manager.Dispose();

if (file != null)
{
file.CheckIn("added web parts");
file.Publish("added web parts");
}
}
}
===============================================================

Thanks!
Avinash Dad

Retrieve webpart connection details programmatically using SPWebPartConnection

If you wish to retrieve the webpart information programmatically then you can use following function.


private void FindConnectedWebPart(SPLimitedWebPartManager wpm)
{
SPWebPartConnectionCollection webPartConColl = wpm.SPWebPartConnections;
try
{
foreach (SPWebPartConnection webPartCon in webPartConColl)
{
string strProviderTitle = RemoveSpecialCharacters(webPartCon.Provider.Title);
string strConsumerTitle = RemoveSpecialCharacters(webPartCon.Consumer.Title);
if (String.Compare(webPartCon.Provider.GetType().Name, "SPSlicerTextWebPart", true) == 0)
{
string strFilterName = ((Microsoft.SharePoint.Portal.WebControls.SPSlicerBaseWebPart)(webPartCon.Provider)).FilterName;
}
TransformableFilterValuesToFilterValuesTransformer transformerMapping = (TransformableFilterValuesToFilterValuesTransformer)webPartCon.Transformer;
// use these details as per your requirements
}
}
catch (Exception ex)
{
// exception detail
}

}


Thanks!
Avinash Dad

Add Web Part programmatically using SPLimitedWebPartManager

Add Web Part programmatically

=========================================================================


public void AddWebPartToPage(string webPartFullName, SPWeb web, string zoneId, int zoneIndex)
{
SPFile file = null;
XmlUrlResolver xmlResolver = new XmlUrlResolver();
xmlResolver.Credentials = CredentialCache.DefaultCredentials;
FileStream fs = new FileStream(webPartFullName, FileMode.OpenOrCreate);
XmlReader reader = new XmlTextReader(fs);
string errorMsg;
SPLimitedWebPartManager manager = null;

try
{
file = web.GetFile(strPageUrl);
if (file.CheckOutStatus == SPFile.SPCheckOutStatus.None)
{
file.CheckOut();
manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);
System.Web.UI.WebControls.WebParts.WebPart tempWebPart = manager.ImportWebPart(reader, out errorMsg);
manager.AddWebPart(tempWebPart, zoneId, zoneIndex);
web.Update();
}
}
catch (Exception ex)
{
// write exception
}
finally
{
if (manager != null)
manager.Dispose();

if (file != null)
{
file.CheckIn("added web parts");
file.Publish("added web parts");
}
if (fs != null)
{
fs.Close();
fs.Dispose();
}

}
}
=========================================================================

this above function can be use for following points:-

Import WebPart programmatically using SPLimitedWebPartManager
or
Add Web Part programmatically using SPLimitedWebPartManager
or
Add Web Part to Page Programmatically

or

any exception comes like this:-
Throws this error on ImportWebPart..."The file you imported is not
valid. Verify that the file is a Web Part description file (*.webpart
or *.dwp) and that it contains well-formed XML."

then its issue with credential. please us CredentialCache.DefaultCredentials as mention in above function.

or

any exception comes like this:-
"Object reference not set to an instance of an object" while ImportWebPart
then its isse with loading file. Dont use File to load use FileStream as mentioned in above function.

or

SPLimitedWebPartManager.AddWebPart():



Thanks!
Avinash Dad

Connect webparts programmatically using SPConnectWebParts

If you wish to connect two webpart where you have webpart consumer and webpart provider object then you can use following idea to implement functionality.

========================================================================
private void ConnectWebPartOnPage(SPWeb oWeb, WebPart webPartConsumer, WebPart webPartProvider, string MappingId)
{
SPFile file = null;
SPLimitedWebPartManager manager = null;
file = oWeb.GetFile(strPageUrl);

try
{
if (file.CheckOutStatus == SPFile.SPCheckOutStatus.None)
{
file.CheckOut();
manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared);

ConsumerConnectionPoint consumerConnection = null;
foreach (ConsumerConnectionPoint point in manager.GetConsumerConnectionPoints(webPartConsumer))
{
if (point.InterfaceType == typeof(IFilterValues))
{
consumerConnection = point; break;
}
}
ProviderConnectionPoint providerConnection = null;
foreach (ProviderConnectionPoint point in manager.GetProviderConnectionPoints(webPartProvider))
{
if (point.InterfaceType == typeof(Microsoft.SharePoint.WebPartPages.ITransformableFilterValues))
{
providerConnection = point; break;
}
}

TransformableFilterValuesToFilterValuesTransformer transformMapping = new TransformableFilterValuesToFilterValuesTransformer();
transformMapping.MappedConsumerParameterName = MappingId;
manager.SPConnectWebParts(webPartProvider, providerConnection, webPartConsumer, consumerConnection, transformMapping);

oWeb.Update();
}
}
catch (Exception ex)
{
// exception here
}
finally
{
if (manager != null)
manager.Dispose();

if (file != null)
{
file.CheckIn("Connected web parts, if any");
file.Publish("Connected web parts, if any");
}
}
}
===============================================================================

this above function can be use for following points:-


Programmatically connect a Consumer WebPart & a Provider WebPart

or

How to connect WebParts Programmatically?

or

Connecting webparts

or

use of ConsumerConnectionPoint and ProviderConnectionPoint

or

use of SPConnectWebParts

or

How to connect Web Parts programmatically in WSS 3


Thanks
Avinash Dad

Monday, May 3, 2010

How to: Pass Values Between ASP.NET Web Pages

Please refer MSDN link:-
http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

Also refer my another article:-
"Pass page values from one to another page in ASP .NET"

http://avinash-moss-expert.blogspot.com/2010/05/transferring-page-values-to-another.html

Thanks!
Avinash

Pass page values from one to another page in ASP .NET

Hi,

To Pass Values Between ASP.NET Web Pages
or
To Transfer page values to another page

we can use following:-

1. Response.Redirect (Use a query string.)
2. Cookies
3. Session Variables
4. Application Variables
5. HttpContext by using Server.Transfer

details:-

Introduction
We always come into situations in which we need to transfer values from one page to another page. In this article, I will show you some ways of transferring values from page to page. The page I created in this example is really simple which consists of a text field and a few buttons. The data entered in the text field will be transferred to another page by using different methods labeled on the buttons.

Using the code
Response.Redirect
Let's first see how to transfer using Response.Redirect method. This maybe the easiest of them all. You start by writing some data in the text field, and when you finish writing the data, you press the button labeled 'Reponse.Redirect'. One tip that I would like to share with you is, sometimes we want to transfer to another page inside the catch exception, meaning exception is caught and we want to transfer to another page. If you try to do this, it may give you a System.Threading exception. This exception is raised because you are transferring to another page leaving behind the thread running. You can solve this problem using:

Response.Redirect("WebForm5.aspx",false);
This tells the compiler to go to page "WebForm5.aspx", and "false" here means that don't end what you were doing on the current page. You should also look at the System.Threading class for threading issues. Below, you can see the C# code of the button event. "txtName" is the name of the text field whose value is being transferred to a page called "WebForm5.aspx". "Name" which is just after "?" sign is just a temporary response variable which will hold the value of the text box.

private void Button1_Click(object sender, System.EventArgs e)
{
    // Value sent using HttpResponse
    Response.Redirect("WebForm5.aspx?Name="+txtName.Text);
}
Okay, up till this point, you have send the values using Response. But now, where do I collect the values, so in the "WebForm5.aspx" page_Load event, write this code. First, we check that the value entered is not null. If it's not, then we simply display the value on the page using a Label control. Note: When you use Response.Redirect method to pass the values, all the values are visible in the URL of the browser. You should never pass credit card numbers and confidential information via Response.Redirect.
if (Request.QueryString["Name"]!= null)
    Label3.Text = Request.QueryString["Name"];
CookiesNext up is cookies. Cookies are created on the server side but saved on the client side. In the button click event of 'Cookies', write this code:
HttpCookie cName = new HttpCookie("Name");
cName.Value = txtName.Text;
Response.Cookies.Add(cName);
Response.Redirect("WebForm5.aspx");
First, we create a cookie named "cName". Since one cookie instance can hold many values, we tell the compiler that this cookie will hold "Name" value. We assign to it the value of the TextBox and finally add it in the Response stream, and sent it to the other page using Response.Redirect method.

Let's see here how we can get the value of the cookie which is sent by one page.
if (Request.Cookies["Name"] != null )
    Label3.Text = Request.Cookies["Name"].Value;
As you see, it's exactly the same way as we did before, but now we are using Request.Cookies instead of Request.QueryString. Remember that some browsers don't accept cookies.

Session Variables
Next we see the session variables which are handled by the server. Sessions are created as soon as the first response is being sent from the client to the server, and session ends when the user closes his browser window or some abnormal operation takes place. Here is how you can use session variables for transferring values. Below you can see a Session is created for the user and "Name" is the key, also known as the Session key, which is assigned the TextBox value.
// Session Created
Session["Name"] = txtName.Text;
Response.Redirect("WebForm5.aspx");

// The code below shows how to get the session value.
// This code must be placed in other page.
if(Session["Name"] != null)
    Label3.Text = Session["Name"].ToString();
Application Variables
Sometimes, we need to access a value from anywhere in our page. For that, you can use Application variables. Here is a small code that shows how to do that. Once you created and assigned the Application variable, you can retrieve its value anywhere in your application.

// This sets the value of the Application Variable
Application["Name"] = txtName.Text; 
Response.Redirect("WebForm5.aspx"); 

// This is how we retrieve the value of the Application Variable
if( Application["Name"] != null ) 
    Label3.Text = Application["Name"].ToString();
HttpContextYou can also use HttpContext to retrieve values from pages. The values are retrieved using properties or methods. It's a good idea to use properties since they are easier to code and modify. In your first page, make a property that returns the value of the TextBox.
public string GetName
{ 
    get { return txtName.Text; }
}
We will use Server.Transfer to send the control to a new page. Note that Server.Transfer only transfers the control to the new page and does not redirect the browser to it, which means you will see the address of the old page in your URL. Simply add the following line of code in 'Server.Transfer' button click event:
Server.Transfer("WebForm5.aspx");
Now, let's go to the page where the values are being transferred, which in this case is "webForm5.aspx".
// You can declare this Globally or in any event you like
WebForm4 w;

// Gets the Page.Context which is Associated with this page 
w = (WebForm4)Context.Handler;
// Assign the Label control with the property "GetName" which returns string
Label3.Text = w.GetName;
please refer actual article at
http://www.codeproject.com/KB/aspnet/TransferingValues.aspx

Thanks & Regards,
Avinash

Tuesday, April 20, 2010

Sharepoint 2007 ( MOSS ) Interview Questions

Hi All,

I have few collection of sharepoint interview questions.
Please find below:-


What does AllowUnsafeUpdates do ?
If your code modifies Windows SharePoint Services data in some way, you may need to allow unsafe updates on the Web site, without requiring a security validation. You can do by setting the AllowUnsafeUpdates property. C#:
view sourceprint?
01.using(SPSite mySite = new SPSite("yourserver"))
02.{ using(SPWeb myWeb = mySite.OpenWeb())
03.{
04.myWeb.AllowUnsafeUpdates = true;
05.SPList interviewList = myWeb.Lists["listtoinsert"];
06.SPListItem newItem = interviewList.Items.Add();
07.newItem["interview"] = "interview";
08.newItem.Update();
09.}
10.}

- What does RunWithElevatedPrivileges do?
Assume that you have a Web Part in which you want to display information obtained through the Windows SharePoint Services object model, such as the name of the current site collection owner, usage statistics, or auditing information. These are examples of calls into the object model that require site-administration privileges. Your Web Part experiences an access-denied error if it attempts to obtain this information when the current user is not a site administrator. The request is initiated by a nonprivileged user. you can still successfully make these calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class. C#:
view sourceprint?
01.SPSite siteColl = SPContext.Current.Site;
02.SPWeb site = SPContext.Current.Web;
03.SPSecurity.RunWithElevatedPrivileges(delegate()
04.{
05.using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
06.{
07.using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))
08.{
09.string SiteCollectionOwner = ElevatedsiteColl.Owner.Name;
10.string Visits = ElevatedsiteColl.Usage.Visits.ToString();
11.string RootAuditEntries = ElevatedSite.RootFolder.Audit.GetEntries().Count.ToString();
12.}
13.}
14.});

- What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances.
Scopes include
• Farm
• WebApplication
• Site (site collection)
• Web (site)
Features have their own receiver architecture, which allow you to trap events such as when a feature is
• installing
• uninstalling
• activated
• deactivated
The element types that can be defined by a feature include
• menu commands
• link commands
• page templates
• page instances
• list definitions
• list instances
• event handlers
• workflows
The two files that are used to define a feature are
• feature.xml
• manifest file(elements.xml)
The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.
Common stsadm commands associated with feature are
• stsadm -o installfeature
• stsadm -o uninstallfeature
• stsadm -o activatefeature
• stsadm -o deactivatefeature

- What are content types ?
A content type is a flexible and reusable WSS type definition that defines the columns and behavior for an item in a list or a document in a document library.
For example,
-you can create a content type for a customer presentation document with a unique set of columns, an event handler, and its own document template.
-You can create a second content type for a customer proposal document with a different set of columns, a workflow, and a different document template.
Then you can attach both the contenttypes to a document library, which allows you to capture metadata based on the contenttype selected during creation of the document.

Content type can be created by the following
• from the rootweb of a site collection, go to Site Action > Site Settings > Galleries > Site content types
• using a feature


5. Workflow can be applied to what all elements of SharePoint ?
While workflow associations are often created directly on lists and document libraries, a workflow association can also be created on a content type that exists within the Content Type Gallery for the current site or content types defined within a list.
In short, it can be applied ...
• At the level of a list (or document library)
• At the level of a content type defined at site scope
• At the level of a site ( Sharepoint 2010 )

- What are the ways to initiate the workflow ?
• Automatic (on item added or item deleted)
• Manual (standard WSS UI interface)
• Manual (Custom UI Interface)
• Programatically through custom code

7. What are the types of input forms that can be created for a workflow ?
You can create four different types of input forms including an association form, an initiation form, a modification form, and a task edit form. Note that these forms are optional when you create a workflow template.

8. What are ways to create input forms for workflow ?
Two different approaches can be used to develop custom input forms for a WSS workflow template.
• You can create your forms by using custom application pages, which are standard .aspx pages deployed to run out of the _layouts directory. ( disadv: lot of code required when compared to Infopath approach)
• using Microsoft Office InfoPath 2007 (disadv: picks up a dependenct on MOSS, i.e. it cannot run in a standalone WSS environment)

9. What is the difference between method activity and event activity in WF ?
A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring.

10. What does SPWeb.EnsureUser method do?
Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site. e.g SPUser usr = myWeb.EnsureUser("mmangaldas");

11. While creating a Webpart, which is the ideal location to Initialize my new controls ?
Override the CreateChildControls method to include your new controls. To make sure that the new controls are initialized.. call 'EnsureChildControls' in the webparts Render method. You can control the exact Rendering of your controls by calling the .Render method in the webparts Render method.

12. How to query from multiple lists ?
Use SPSiteDataQuery to fetch data from multiple lists. more details..

13.How Does SharePoint work?
The browser sends a DAV packet to IIS asking to perform a document check in. PKMDASL.DLL, an ISAPI DLL, parses the packet and sees that it has the proprietary INVOKE command. Because of the existence of this command, the packet is passed off to msdmserv.exe, who in turn processes the packet and uses EXOLEDB to access the WSS, perform the operation and send the results back to the user in the form of XML.

14. What is the difference between Syncronous & Asyncronous events?
Syncronous calls ending with 'ing' E.g. ItemDeleting Event Handler code execute BEFORE action is committed WSS waits for code to return Option to cancel and return error code
Asyncronous calls ending with 'ed' E.g. ItemDeleted Event Handler code executes AFTER action is committed WSS does not wait for code to return Executed in its own Worker thread.

15. What is ServerUpdate() ?
Any changes in the list, i.e. new addition or modification of an item.. the operation is complete by calling the Update method.But if a List is set to maintain versions .. and you are editing an item, but don't want to save it as a new version, then use the SystemUpdate method instead and pass in 'false' as the parameter.

16. What is query.ViewAttributes OR How can you force SPQuery to return results from all the folders of the list?
If you use SPQuery on any SPlist .. it will bring back results from the current folder only. If you want to get results from all the folders in the list.. then you need to specify the scope of the query by the use of ViewAttributes..
e.g. query.ViewAttributes = "Scope=\"Recursive\"";

- What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?
There are two base classes that a WebPart which is going to be consumed by SharePoint can inherit from, either the SharePoint WebPart Base class or the ASP.NET 2.0 WebPart base class. When inheriting from the SharePoint WebPart Base class your derived WebPart class will inherit from Microsoft.SharePoint.WebPartPages.WebPart. When inheriting from the ASP.NET 2.0 WebPart base class your derived WebPart class will inherit from System.Web.UI.WebControls.WebParts.WebPart. It is considered good practice to use the ASP.NET WebPart base class since the old base class is meant for backwards compatibility with previous version of SharePoint, however there are four exception when it is better to leverage functionality from the SharePoint WebPart base class:
• Cross page connections
• Connections between Web Parts that are outside of a Web Part zone
• Client-side connections (Web Part Page Services Component)
• Data caching infrastructure

- What are the differences between the two base classes and what are the inherit benefits of using one over another?
The difference is the Microsoft.SharePoint.WebPartPages.WebPart base class is meant for backward compatibility with previous versions of SharePoint. The benefit of using the SharePoint WebPart base class is it supported:
• Cross page connections
• Connections between Web Parts that are outside of a Web Part zone
• Client-side connections (Web Part Page Services Component)
• Data caching infrastructure
ASP.NET 2.0 WebParts are generally considered better to use because SharePoint is built upon the ASP.NET 2.0 web architecture. Inheriting from the ASP.NET 2.0 base class offers you features that inherit to ASP.NET 2.0, such as embedding resources as opposed to use ClassResources for deployment of said types.

- What is the GAC?
The GAC stands for the global assembly cache. It is the machine wide code cache which will give custom binaries place into the full trust code group for SharePoint. Certain SharePoint assets, such as Feature Receivers need full trust to run correctly, and therefore are put into the GAC. You should always try to avoid deployment to the GAC as much as possible since it will possibly allow development code to do more than it was intended to do.

- What is strong naming (signing) a WebPart assembly file mean?
Signing an assembly with a strong name (a.k.a strong naming) uses a cryptographic key pair that gives a unique identity to a component that is being built. This identity can then be referred throughout the rest of the environment. In order to install assemblies into the GAC, they must be strongly named. After signing, the binary will have a public key token identifier which can be use to register the component in various other places on the server.

- What are safe controls, and what type of information, is placed in that element in a SharePoint web.config file?
When you deploy a WebPart to SharePoint, you must first make it as a safe control to use within SharePoint in the web.config file. Entries made in the safe controls element of SharePoint are encountered by the SharePointHandler object and will be loaded in the SharePoint environment properly, those not will not be loaded and will throw an error.
In the generic safe control entry (this is general, there could be more), there is generally the Assembly name, the namespace, the public key token numeric, the typename, and the safe declaration (whether it is safe or not). There are other optional elements.

- What is the CreateChildControls() method? How can you use it to do something simple like displaying a Label control?
The CreateChildControls method in WebParts is used to notify the WebPart that there are children controls that should be output for rendering. Basically, it will add any child ASP.NET controls that are called instantiating each control with its relevant properties set, wire any relevant event handlers to the control, etc. Then the add method of the control class will add the control to the controls collection. In the relevant WebPart render method, the EnsureChildControls method can be called (or set to false if no child controls should be called) to ensure that the CreateChildControls method is run. When using CreateChildControls it implies that your WebPart contains a composition of child controls.
In order to create something like a label control in Create, you would create a new label control using the new keyword, set the various properties of the control like Visible=True and ForeColor = Color.Red, and then use Controls.Add(myLabelControl) to add the control to the controls collection. Then you can declare EnsureChildControls in the Render method of the WebPart.

- What does the RenderContents method do in an ASP.NET 2.0 WebPart?
The render contents method will render the WebPart content to the writer, usually an HtmlTextWriter since WebParts will output to an HTML stream. RenderContents is used to tell how the controls that are going to be displayed in the WebPart should be rendered on the page.
*** Side Question: I got asked what the difference between CreateChildControls and the RenderContents method. The CreateChildControls method is used to add controls to the WebPart, and the RenderContents method is used to tell the page framework how to render the control into HTML to display on a page.

- What is the WebPartManager sealed class? What is its purpose?
The WebPartManager sealed class is responsible for managing everything occurring on a WebPart page, such as the WebParts (controls), events, and misc. functionality that will occur in WebPartZones. For example, the WebPartManager is responsible for the functionality that is provided when you are working with moving a WebPart from WebPartZone to WebPartZone. It is known as the “the central class of the Web Part Control Set.”
*** Side Question: I got asked how many WebPartManager controls should be on a page. In order to have WebParts on a page there has to be just one WebPartManager control to manage all the WebParts on the page.

- What is a SPSite and SPWeb object, and what is the difference between each of the objects?
The SPSite object represents a collection of sites (site collection [a top level sites and all its subsites]). The SPWeb object represents an instance SharePoint Web, and SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them.

- How would you go about getting a reference to a site?
view sourceprint?
1.C#:
2.oSPSite = new SPSite("http:/server");
3.
4.oSPWeb = oSPSite.OpenWeb();

- What does a SPWebApplication object represent?
The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code.

- Would you use SPWebApplication to get information like the SMTP address of the SharePoint site?
Yes, since this is a Web Application level setting. You would iterate through each SPWebApplication in the SPWebApplication collection, and then use the appropriate property calls (OutboundMailServiceInstance) in order to return settings regarding the mail service such as the SMTP address.
Side Question: I got asked if there are other ways to send emails from SharePoint. The answer is yes, there is. You can use the SendMail method from the SPutility class to send simple emails, however it is not as robust as using the System.Net.Mail functionality since it doesn’t allow things like setting priorities on the email.

- How do you connect (reference) to a SharePoint list, and how do you insert a new List Item?
view sourceprint?
01.C#:
02.using(SPSite mySite = new SPSite("yourserver"))
03.{
04.using(SPWeb myWeb = mySite.OpenWeb())
05.{
06.SPList interviewList = myWeb.Lists["listtoinsert"];
07.SPListItem newItem = interviewList.Items.Add();
08.
09.newItem["interview"] = "interview";
10.newItem.Update();
11.}
12.}

- How would you loop using SPList through all SharePont List items, assuming you know the name (in a string value) of the list you want to iterate through, and already have all the site code written?
view sourceprint?
1.C#:
2.SPList interviewList = myWeb.Lists["listtoiterate"];
3.foreach (SPListItem interview in interviewList)
4.{
5.// Do Something
6.}

- How do you return SharePoint List items using SharePoint web services?
In order to retrieve list items from a SharePoint list through Web Services, you should use the lists.asmx web service by establishing a web reference in Visual Studio. The lists.asmx exposes the GetListItems method, which will allow the return of the full content of the list in an XML node. It will take parameters like the GUID of the name of the list you are querying against, the GUID of the view you are going to query, etc.
Side Question: I got asked how I built queries with the lists.asmx web service. In order to build queries with this service, one of the parameters that the GetListItems method exposes is the option to build a CAML query. There are other ways to do this as well, but that was how I answered it.



- What is the difference between an Internet and an intranet site?
An internet site is a normal site that anyone on the internet can access (e.g., www.msn.com, www.microsoft.com, etc.). You can set up a site for your company that can be accessed by anyone without any user name and password.
An intranet (or internal network), though hosted on the Web, can only be accessed by people who are members of the network. They need to have a login and password that was assigned to them when they were added to the site by the site administrator

- What are the various kinds of roles the users can have?
A user can be assigned one of the following roles
• Reader - Has read-only access to the Web site.
• Contributor - Can add content to existing document libraries and lists.
• Web Designer - Can create lists and document libraries and customize pages in the Web site.
• Administrator - Has full control of the Web site.

- How customizable is the user-to-user access?
User permissions apply to an entire Web, not to documents themselves. However, you can have additional sub webs that can optionally have their own permissions. Each user can be given any of four default roles. Additional roles can be defined by the administrator.
Can each user have access to their own calendar?
Yes there are two ways to do this,
• by creating a calendar for each user, or
• by creating a calendar with a view for each user

- Can SharePoint be linked to a SQL database?
This is possible via a custom application, but it not natively supported by SharePoint or SQL Server.

- What does partial trust mean the Web Part developer?
If an assembly is installed into the BIN directory, the code must be ensured that provides error handling in the event that required permissions are not available. Otherwise, unhandled security exceptions may cause the Web Part to fail and may affect page rendering on the page where the Web Part appears

- How can I raise the trust level for assemblies installed in the BIN directory?
Windows SharePoint Services can use any of the following three options from ASP.NET and the CLR to provide assemblies installed in the BIN directory with sufficient permissions. The following table outlines the implications and requirements for each option.
Option Pros Cons
Increase the trust level for the entire virtual server. For more information, see "Setting the trust level for a virtual server" Easy to implement.
In a development environment, increasing the trust level allows you to test an assembly with increased permissions while allowing you to recompile assemblies directly into the BIN directory without resetting IIS. This option is least secure.
This option affects all assemblies used by the virtual server.

There is no guarantee the destination server has the required trust level. Therefore, Web Parts may not work once installed on the destination server.
Create a custom policy file for your assemblies. For more information, see "How do I create a custom policy file?" Recommended approach.
This option is most secure.

An assembly can operate with a unique policy that meets the minimum permission requirements for the assembly.

By creating a custom security policy, you can ensure the destination server can run your Web Parts. Requires the most configuration of all three options.
Install your assemblies in the GAC Easy to implement.
This grants Full trust to your assembly without affecting the trust level of assemblies installed in the BIN directory. This option is less secure.
Assemblies installed in the GAC are available to all virtual servers and applications on a server running Windows SharePoint Services. This could represent a potential security risk as it potentially grants a higher level of permission to your assembly across a larger scope than necessary

In a development environment, you must reset IIS every time you recompile assemblies.

Licensing issues may arise due to the global availability of your assembly.


- When retrieving List items using SharePoint Web Services, how do you specify explicit credentials to be passed to access the list items?
In order to specify explicit credentials with a Web Service, you generally instantiate the web service, and then using the credentials properties of the Web Service object you use the System.Net.NetworkCredential class to specify the username, password, and domain that you wish to pass when making the web service call and operations.
*** Side Question: I got asked when you should state the credentials in code. You must state the credentials you are going to pass to the web service before you call any of the methods of the web service, otherwise the call will fail.

- What is CAML, and why would you use it?
CAML stands for Collaborative Application Markup Language. CAML is an XML based language which provides data constructs that build up the SharePoint fields, view, and is used for table definition during site provisioning. CAML is responsible for rending data and the resulting HTML that is output to the user in SharePoint. CAML can be used for a variety of circumstances, overall is used to query, build and customize SharePoint based sites. A general use would be building a CAML query in a SharePoint WebPart in order to retrieve values from a SharePoint list.

- What is impersonation, and when would you use impersonation?
Impersonation can basically provide the functionality of executing something in the context of a different identity, for example assigning an account to users with anonymous access. You would use impersonation in order to access resources on behalf of the user with a different account, that normally, that wouldn’t be able to access or execute something.

- What is the IDesignTimeHtmlProvider interface, and when can you use it in WebParts?
The IDesignTimeHtmlProvider interface uses the function GetDesignTimeHtml() which can contain your relevant render methods. It was helpful to use in 2003 since it allowed your WebPart to have a preview while a page was edited in FrontPage with the Webpart on it, because the GetDesignTimeHtml() method contains the HTML for the designer to render.

- What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?
WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.

- Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?
Properties are important because WebParts allow levels of personalization for each user. WebPart properties make it possible for a user to interact, adjust, and increase overall experience value with the programmatic assets that you develop without having the need to use an external editor or right any code. A very simple example of exploiting a property would be something like allowing the user to change the text on the WebPart design interface so that they can display whatever string of text they desire.
Each custom property that you have must have the appropriate get and set accessor methods.

- What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?
ClassResources are used when inheriting from the SharePoint.WebPart.WebPartPages.WebPart base class, and are defined in the SharePoint solution file as things that should be stored in the wpresources directory on the server. It is a helpful directory to use in order to deploy custom images. In ASP.NET 2.0, typically things such as images are referenced by embedding them as resources within an assembly. The good part about ClassResources is they can help to eliminate recompiles to change small interface adjustments or alterations to external JavaScript files.

- What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?
A SharePoint solution file is essentially a .cabinet file with all a developers ustom componets suffixed with a .wsp extension that aids in deployment. The big difference with SharePoint solution files is is that a solution:
allows deployment to all WFE’s in a farm
is highly manageable from the interface allowing deployment, retraction, and versioning
Can package all types of assets like site definitions, feature definitions (and associated components), Webparts, etc.
Can provide Code Access Security provisioning to avoid GAC deployments
Just to name a few things…

- What is a .ddf file and what does it have to do with SharePoint Solution creation?
A .ddf file is a data directive file and is used when building the SharePoint solution bundle specifying the source files and their destination locations. The important thing for someone to understand is that the .ddf file will be passed as a parameter to the MAKECAB utility to orchestrate construction of the SharePoint solution file.

- What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?
The solution Manifest.XML file.


- What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?
SharePoint solution files can add in order to handle code access security deployment issues. This is done in the element in the SharePoint solution manifest.XML, which makes it easier to get assemblies the appropriate permissions in order to operate in the bin directory of the web application.

- What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, such as at the farm, site collection, web, etc. Features have their own receiver architecture, which allow you to trap events such as when a feature is installing, uninstalling, activated, or deactivated. They are helpful because they allow ease of upgrades and versioning.
The two files that are used to define a feature are the feature.xml and manifest file. The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.
Side Question: I got asked how the introduction of features has changed the concept of site definitions. SharePoint features are important when understanding the architecture of site definitions, since the ONET.XML file has been vastly truncated since it has several feature stapled on it.

- What types of SharePoint assets can be deployed with a SharePoint feature?
Features can do a lot. For example, you could deploy
• Simple site customizations
• Custom site navigation
• WebParts
• pages
• list types
• list instances
• event handlers
• workflows
• custom actions

- What are event receivers?
Event receivers are classes that inherit from the SpItemEventReciever or SPListEventReciever base class (both of which derive out of the abstract base class SPEventRecieverBase), and provide the option of responding to events as they occur within SharePoint, such as adding an item or deleting an item.

- When would you use an event receiver?
Since event receivers respond to events, you could use a receiver for something as simple as canceling an action, such as deleting a document library by using the Cancel property. This would essentially prevent users from deleting any documents if you wanted to maintain retention of stored data.

- What base class do event receivers inherit from?
Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.

- If I wanted to not allow people to delete documents from a document library, how would I go about it?
You would on the ItemDeleting event set: properties.Cancel= true.
33) What is the difference between an asynchronous and synchronous event receivers?
An asynchronous event occurs after an action has taken place, and a synchronous event occurs before an action has take place. For example, an asynchronous event is ItemAdded, and its sister synchronous event is ItemAdding.

- How could you append a string to the title of a site when it is provisioned?
In the OnActivated event:
view sourceprint?
1.SPWeb site = siteCollection.RootWeb;
2.site.Title += "interview";
3.site.Update();

- Can an event receiver be deployed through a SharePoint feature?
Yes.

- What is a content type?
A content type is an information blueprint basically that can be re-used throughout a SharePoint environment for defining things like metadata and associated behaviors. It is basically an extension of a SharePoint list, however makes it portable for use throughout an instance regardless of where the instantiation occurs, ergo has location independence. Multiple content types can exist in one document library assuming that the appropriate document library settings are enabled. The content type will contain things like the metadata, listform pages, workflows, templates (if a document content type), and associated custom written functionality.

- Can a content type have receivers associated with it?
Yes, a content type can have an event receiver associated with it, either inheriting from the SPListEventReciever base class for list level events, or inheriting from the SPItemEventReciever base class. Whenever the content type is instantiated, it will be subject to the event receivers that are associated with it.

- What two files are typically (this is kept generally) included when developing a content type, and what is the purpose of each?
There is generally the main content type file that holds things like the content type ID, name, group, description, and version. There is also the ContentType.Fields file which contains the fields to include in the content type that has the ID, Type, Name, DisplayName, StaticName, Hidden, Required, and Sealed elements. They are related by the FieldRefs element in the main content type file.

- What is an ancestral type and what does it have to do with content types?
An ancestral type is the base type that the content type is deriving from, such as Document (0x0101). The ancestral type will define the metadata fields that are included with the custom content type.

- Can a list definition be derived from a custom content type?
Yes, a list definition can derive from a content type which can be seen in the schema.XML of the list definition in the element.

- When creating a list definition, how can you create an instance of the list?
You can create a new instance of a list by creating an instance.XML file.

- What is a Field Control?
Field controls are simple ASP.NET 2.0 server controls that provide the basic field functionality of SharePoint. They provide basic general functionality such as displaying or editing list data as it appears on SharePoint list pages.

- What base class do custom Field Controls inherit from?
This varies. Generally, custom field controls inherit from the Microsoft.SharePoint.WebControls.BaseFieldControl namespace, but you can inherit from the default field controls.

- What is a SharePoint site definition? What is ghosted (uncustomized) and unghosted (customized)?
SharePoint site definitions are the core set of functionality from which SharePoint site are built from, building from the SiteTemplates directory in the SharePoint 12 hive. Site definitions allow several sites to inherit from a core set of files on the file system, although appear to have unique pages, thereby increasing performance and allowing changes that happen to a site propagate to all sites that inherit from a site definition. Ghosted means that when SharePoint creates a new site it will reference the files in the related site definition upon site provisioning. Unghosted means that the site has been edited with an external editor, and therefore the customizations are instead stored in the database, breaking the inheritance of those files from the file system.

- How does one deploy new SharePoint site definitions so that they are made aware to the SharePoint system?
The best way to deploy site definitions in the SharePoint 2007 framework is to use a SharePoint solution file, so that the new site definition is automatically populated to all WFE’s in the SharePoint farm.

- What is an ancestral type and what does it have to do with content types?
An ancestral type is the base type that the content type is deriving from, such as Document (0x0101). The ancestral type will define the metadata fields that are included with the custom content type.

- Can a list definition be derived from a custom content type?
Yes, a list definition can derive from a content type which can be seen in the schema.XML of the list definition in the element.

- When creating a list definition, how can you create an instance of the list?
You can create a new instance of a list by creating an instance.XML file

- What is a Field Control?
Field controls are simple ASP.NET 2.0 server controls that provide the basic field functionality of SharePoint. They provide basic general functionality such as displaying or editing list data as it appears on SharePoint list pages.

- What base class do custom Field Controls inherit from?
This varies. Generally, custom field controls inherit from the Microsoft.SharePoint.WebControls.BaseFieldControl namespace, but you can inherit from the default field controls.

- Can multiple SharePoint installs point to the same DB?
Multiple SharePoint installs can use the same database server. Not literally the same database on that server. That server must be SQL Server 2000 or SQL Server 2005. It cannot be Oracle or another vendor.

- How to create links to the mapped network drives?
Creating links to mapped drives in WSS v3 or MOSS 2007 can be done via the new content type for .lnk files.

- While creating a Web part, which is the ideal location to Initialize my new controls?
Override the CreateChildControls method to include your new controls. You can control the exact rendering of your controls by calling the .Render method in the web parts Render method.

- What is the WebPartManager sealed class? What is its purpose?
The WebPartManager sealed class is responsible for managing everything occurring on a WebPart page, such as the WebParts (controls), events, and misc. functionality that will occur in WebPartZones. For example, the WebPartManager is responsible for the functionality that is provided when you are working with moving a WebPart from WebPartZone to WebPartZone. It is known as the “the central class of the Web Part Control Set.”

- What is a SPSite and SPWeb object, and what is the difference between each of the objects?
The SPSite object represents a collection of sites (site collection [a top level site and all its subsites]). The SPWeb object represents an instance SharePoint Web, and SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them.

- What does a SPWebApplication object represent?
The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code.

- Would you use SPWebApplication to get information like the SMTP address of the SharePoint site?
Yes, since this is a Web Application level setting. You would iterate through each SPWebApplication in the SPWebApplication collection, and then use the appropriate property calls (OutboundMailServiceInstance) in order to return settings regarding the mail service such as the SMTP address.

- How do you return SharePoint List items using SharePoint web services?
In order to retrieve list items from a SharePoint list through Web Services, you should use the lists.asmx web service by establishing a web reference in Visual Studio. The lists.asmx exposes the GetListItems method, which will allow the return of the full content of the list in an XML node. It will take parameters like the GUID of the name of the list you are querying against, the GUID of the view you are going to query, etc.
Side Question: I got asked how I built queries with the lists.asmx web service. In order to build queries with this service, one of the parameters that the GetListItems method exposes is the option to build a CAML query. There are other ways to do this as well, but that was how I answered it.

- When retrieving List items using SharePoint Web Services, how do you specify explicit credentials to be passed to access the list items?
In order to specify explicit credentials with a Web Service, you generally instantiate the web service, and then using the credentials properties of the Web Service object you use the System.Net.NetworkCredential class to specify the username, password, and domain that you wish to pass when making the web service call and operations.

- What is CAML, and why would you use it?
CAML stands for Collaborative Application Markup Language. CAML is an XML based language which provides data constructs that build up the SharePoint fields, view, and is used for table definition during site provisioning. CAML is responsible for rending data and the resulting HTML that is output to the user in SharePoint. CAML can be used for a variety of circumstances, overall is used to query, build and customize SharePoint based sites. A general use would be building a CAML query in a SharePoint WebPart in order to retrieve values from a SharePoint list.

- What is impersonation, and when would you use impersonation?
Impersonation can basically provide the functionality of executing something in the context of a different identity, for example assigning an account to users with anonymous access. You would use impersonation in order to access resources on behalf of the user with a different account, that normally, that wouldn’t be able to access or execute something.

- What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?
WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.

- Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?
Properties are important because WebParts allow levels of personalization for each user. WebPart properties make it possible for a user to interact, adjust, and increase overall experience value with the programmatic assets that you develop without having the need to use an external editor or right any code. A very simple example of exploiting a property would be something like allowing the user to change the text on the WebPart design interface so that they can display whatever string of text they desire.
Each custom property that you have must have the appropriate get and set accessor methods.

- What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?
ClassResources are used when inheriting from the SharePoint.WebPart.WebPartPages.WebPart base class, and are defined in the SharePoint solution file as things that should be stored in the wpresources directory on the server. It is a helpful directory to use in order to deploy custom images. In ASP.NET 2.0, typically things such as images are referenced by embedding them as resources within an assembly. The good part about ClassResources is they can help to eliminate recompiles to change small interface adjustments or alterations to external JavaScript files.

- What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?
A SharePoint solution file is essentially a .cabinet file with all a developers ustom componets suffixed with a .wsp extension that aids in deployment. The big difference with SharePoint solution files is is that a solution:
allows deployment to all WFE’s in a farm
is highly manageable from the interface allowing deployment, retraction, and versioning
Can package all types of assets like site definitions, feature definitions (and associated components), Webparts, etc.
Can provide Code Access Security provisioning to avoid GAC deployments
And much more..

- What is a .ddf file and what does it have to do with SharePoint Solution creation?
.ddf file is a data directive file and is used when building the SharePoint solution bundle specifying the source files and their destination locations. The important thing for someone to understand is that the .ddf file will be passed as a parameter to the MAKECAB utility to orchestrate construction of the SharePoint solution file.

- What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?
The solution Manifest.XML file.

- What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?
SharePoint solution files can add in order to handle code access security deployment issues. This is done in the element in the SharePoint solution manifest.XML, which makes it easier to get assemblies the appropriate permissions in order to operate in the bin directory of the web application.

- When would you use an event receiver?
Since event receivers respond to events, you could use a receiver for something as simple as canceling an action, such as deleting a document library by using the Cancel property. This would essentially prevent users from deleting any documents if you wanted to maintain retention of stored data.

- What base class do event receivers inherit from?
Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.

- If I wanted to not allow people to delete documents from a document library, how would I go about it?
You would on the ItemDeleting event set: properties.Cancel= true.

- When running with SPSecurity.RunWithElevatedPrivileges (web context) what credentials are being used?
In a web context, this is the application pool identity. In a timer job and workflow, this will be the 'Windows SharePoint Timer Services' identity.

- When should you dispose SPWeb and SPSite objects? And even more important, when not?
You should always dispose them if you created them yourself, but not otherwise. You should never dispose SPContext.Current.Web/Site and you should normally not dispose SPWeb if IsRootWeb is true. More tricky constructs are things along the line of SPList.ParentWeb.
Also dispose each web when iterating over SPWeb.Webs
Also dispose SPLimitedWebPartManager's SPWeb property (.web)

- What bugs have you found in SharePoint? And what did you do to work around them?

- What base classes do event receivers inherit from?
SPListEventReceiver, SPItemEventReciever, and SPWebEventReceiver inherit from the abstract base class SPEventReceiverBase.
SPWorkflowLibraryEventReceiver inherits from SPItemEventReceiver.
SPEmailEventReceiver inherits directly from System.Object.

- What are the built in ways to backup a SharePoint install?
A: Through the central administration and the stsadm command

- (more advanced) You've created and deployed a Web Part, when you deploy to the server you get a page saying your Web Part couldn't be loaded, click here to go to the Web Part maintenance page, etc. to disable the web part. What step(s) should you take to get a stack dump from your web part instead of that error page?
Go to the web.config file for your website and find the CallStack Attribute in the SafeControls element and set the value to true

- How would you programmatically retrieve a list item?
SPQuery and SPSiteDataQuery. Bonus points for knowledge of CrossListQueryCache, PortalSiteMapProvider. Negative points for use of foreach.

- What are the data types which are supported as Lookup column in SharePoint.
Only Single Line of Text and Calculated columns are supported as lookup columns.

- how can debugging share point application and timer jobs ? with steps?
1. build application place .dll into gac and reset iis
2. On the Debug menu, select Attach to Process
3. select the Show processes from all users check box.
4. select W3W.exe and OSWTIMER.exe can attach
5. refresh sharepoint site point break point

- what is web part?
Web Parts are the fundamental building blocks for Share Point user interface, and with them we can build and integrate many different types of applications.In share point also be create custom web part using .oscx control
steps create custom web part
1. create web part project copied .oscx control and build application.place .dll file in GAC .reset IIS.
2. go 12 hive _layout folder create folder past your .oscx control
3. go inetpub ->wwwroot->wss->open Your site ->web con fig->create safe control write assembly information of web part application
4. open sharepoint site ->site action-site editing->Galleries ->web part->new Add your web part.
follow few web part in WSS 3.0
Content Editor Web Part
Data View Web Part
List View Web Part
Image Web Part
Members Web Part .
Page Viewer Web Part

- What are the advantages of SharePoint Portal Services (SPS) over SharePoint Team Services (STS)?
harePoint Portal Services (SPS) has MUCH better document management. It has check-in, check-out, versioning, approval, publishing, subscriptions, categories, etc. STS does not have these features, or they are very scaled back. SharePoint Portal Services (SPS) has a better search engine, and can crawl multiple content sources. STS cannot. STS is easier to manage and much better for a team environment where there is not much Document Management going on. SPS is better for an organization, or where Document Management is crucial.


• What is the relationship between Microsoft SharePoint Portal Server and Microsoft Windows Services?
Microsoft SharePoint Products and Technologies (including SharePoint Portal Server and Windows SharePoint Services) deliver highly scalable collaboration solutions with flexible deployment and management tools. Windows SharePoint Services provides sites for team collaboration, while Share Point Portal Server connects these sites, people, and business processes-facilitating knowledge sharing and smart organizations. SharePoint Portal Server also extends the capabilities of Windows SharePoint Services by providing organizational and management tools for SharePoint sites, and by enabling teams to publish information to the entire organization.

• What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances, scope of which are defined as
1. Farm level 2. Web Application level 3. Site level 4. Web level
Features have their own receiver architecture, which allow you to trap events such as when a feature is
Installing, Uninstalling, Activated, or Deactivated.

The element types that can be defined by a feature include
menu commands, link commands, page templates, page instances, list definitions, list instances,
event handlers, and workflows.

The two files that are used to define a feature are the feature.xml and manifest file(elements.xml). The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.


• Workflow can be applied to what all elements of SharePoint ?
Workflow associations are often created directly on lists and libraries, a workflow association can also be created on a content type that exists within the Content Type Gallery for the current site or content types defined within a list. In short, it can be applied ...
At the level of a list/library
At the level of a content type defined at site scope
At the level of a content type defined at list scope

• What are the types of input forms that can be created for a workflow ?
You can create four different types of input forms including
1. An association form
2. An initiation form
3. A modification form
4. A task edit form.

Note that these forms are optional when you create a workflow template.

• What are ways to create input forms for workflow ?
Two
1. You can create your forms by using custom application pages, which are standard .aspx pages deployed to run out of the _layouts directory. ( disadv: lot of code required when compared to Infopath approach)
2. Using Microsoft Office InfoPath 2007 (disadv: picks up a dependenct on MOSS, i.e. it cannot run in a standalone WSS environment)

• What is the difference between method activity and event activity in WorkFlow ?
A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring.

• What are content types?
A content type is a flexible and reusable WSS type definition (or we can a template) that defines the columns and behavior for an item in a list or a document in a document library. For example, you can create a content type for a leave approval document with a unique set of columns, an event handler, and its own document template and attach it with a document library/libraries.
• Can a content type have receivers associated with it?
Yes, a content type can have an event receiver associated with it, either inheriting from the SPListEventReciever base class for list level events, or inheriting from the SPItemEventReciever base class. Whenever the content type is instantiated, it will be subject to the event receivers that are associated with it.

• What two files are typically (this is kept generally) included when developing a content type, and what is the purpose of each?
There is generally the main content type file that holds things like the content type ID, name, group, description, and version. There is also the ContentType.Fields file which contains the fields to include in the content type that has the ID, Type, Name, DisplayName, StaticName, Hidden, Required, and Sealed elements. They are related by the FieldRefs element in the main content type file.

• What is an ancestral type and what does it have to do with content types?
An ancestral type is the base type that the content type is deriving from, such as Document (0x0101). The ancestral type will define the metadata fields that are included with the custom content type.

• Can a list definition be derived from a custom content type?
Yes, a list definition can derive from a content type which can be seen in the schema.XML of the list definition in the element.

• When creating a list definition, how can you create an instance of the list?
You can create a new instance of a list by creating an instance.XML file

• What is a Field Control?
Field controls are simple ASP.NET 2.0 server controls that provide the basic field functionality of SharePoint. They provide basic general functionality such as displaying or editing list data as it appears on SharePoint list pages.

• What base class do custom Field Controls inherit from?
This varies. Generally, custom field controls inherit from the Microsoft.SharePoint.WebControls.BaseFieldControl namespace, but you can inherit from the default field controls.

• Can multiple SharePoint installs point to the same DB?
Multiple SharePoint installs can use the same database server. Not literally the same database on that server. That server must be SQL Server 2000 or SQL Server 2005. It cannot be Oracle or another vendor.

• How to create links to the mapped network drives?
Creating links to mapped drives in WSS v3 or MOSS 2007 can be done via
the new content type for .lnk files.

• While creating a Web part, which is the ideal location to Initialize my new controls?
Override the CreateChildControls method to include your new controls. You can control the exact rendering of your controls by calling the .Render method in the web parts Render method.

• What are the two base classes a WebPart you are going to use within SharePoint 2007 can inherit from?
There are two base classes that a WebPart which is going to be consumed by SharePoint can inherit from, either the
SharePoint WebPart Base class
or the
ASP.NET 2.0 WebPart base class.
When inheriting from the SharePoint WebPart Base class your derived WebPart class will inherit from Microsoft.SharePoint.WebPartPages.WebPart. When inheriting from the ASP.NET 2.0 WebPart base class your derived WebPart class will inherit from System.Web.UI.WebControls.WebParts.WebPart. It is considered good practice to use the ASP.NET WebPart base class since the old base class is meant for backwards compatibility with previous version of SharePoint, however there are four exception when it is better to leverage functionality from the SharePoint WebPart base class:
Cross page connections
Connections between Web Parts that are outside of a Web Part zone
Client-side connections (Web Part Page Services Component)
Data caching infrastructure

• What are the differences between the two base classes and what are the inherit benefits of using one over another?
The difference is the Microsoft.SharePoint.WebPartPages.WebPart base class is meant for backward compatibility with previous versions of SharePoint. The benefit of using the SharePoint WebPart base class is it supported:
Cross page connections
Connections between Web Parts that are outside of a Web Part zone
Client-side connections (Web Part Page Services Component)
Data caching infrastructure
ASP.NET 2.0 WebParts are generally considered better to use because SharePoint is built upon the ASP.NET 2.0 web architecture. Inheriting from the ASP.NET 2.0 base class offers you features that inherit to ASP.NET 2.0, such as embedding resources as opposed to use ClassResources for deployment of said types.

• What is the WebPartManager sealed class? What is its purpose?
The WebPartManager sealed class is responsible for managing everything occurring on a WebPart page, such as the WebParts (controls), events, and misc. functionality that will occur in WebPartZones. For example, the WebPartManager is responsible for the functionality that is provided when you are working with moving a WebPart from WebPartZone to WebPartZone. It is known as the “the central class of the Web Part Control Set.”

• What does AllowUnsafeUpdates do ?
If your code modifies Windows SharePoint Services data in some way, you may need to allow unsafe updates on the Web site, without requiring a security validation. You can do by setting the AllowUnsafeUpdates property.

• What does RunWithElevatedPrivileges do?
There are certain object model calls model that require site-administration privileges. To bypass access-denied error, we use RunWithElevatedPrivileges property when request is initiated by a nonprivileged user. We can successfully make calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class.
• What does SPWeb.EnsureUser method do?
Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site.
e.g SPUser usr = myWeb.EnsureUser("hitenders");

• What is a SPSite and SPWeb object, and what is the difference between each of the objects?
The SPSite object represents a collection of sites (site collection [a top level site and all its subsites]). The SPWeb object represents an instance SharePoint Web, and SPWeb object contains things like the actual content. A SPSite object contains the various subsites and the information regarding them.

• What does a SPWebApplication object represent?
The SPWebApplication objects represents a SharePoint Web Application, which essentially is an IIS virtual server. Using the class you can instigate high level operations, such as getting all the features of an entire Web Application instance, or doing high level creation operations like creating new Web Applications through code.

• Would you use SPWebApplication to get information like the SMTP address of the SharePoint site?
Yes, since this is a Web Application level setting. You would iterate through each SPWebApplication in the SPWebApplication collection, and then use the appropriate property calls (OutboundMailServiceInstance) in order to return settings regarding the mail service such as the SMTP address.

• How do you return SharePoint List items using SharePoint web services?
In order to retrieve list items from a SharePoint list through Web Services, you should use the lists.asmx web service by establishing a web reference in Visual Studio. The lists.asmx exposes the GetListItems method, which will allow the return of the full content of the list in an XML node. It will take parameters like the GUID of the name of the list you are querying against, the GUID of the view you are going to query, etc.
Side Question: I got asked how I built queries with the lists.asmx web service. In order to build queries with this service, one of the parameters that the GetListItems method exposes is the option to build a CAML query. There are other ways to do this as well, but that was how I answered it.

• When retrieving List items using SharePoint Web Services, how do you specify explicit credentials to be passed to access the list items?
In order to specify explicit credentials with a Web Service, you generally instantiate the web service, and then using the credentials properties of the Web Service object you use the System.Net.NetworkCredential class to specify the username, password, and domain that you wish to pass when making the web service call and operations.

• What is CAML, and why would you use it?
CAML stands for Collaborative Application Markup Language. CAML is an XML based language which provides data constructs that build up the SharePoint fields, view, and is used for table definition during site provisioning. CAML is responsible for rending data and the resulting HTML that is output to the user in SharePoint. CAML can be used for a variety of circumstances, overall is used to query, build and customize SharePoint based sites. A general use would be building a CAML query in a SharePoint WebPart in order to retrieve values from a SharePoint list.

• What is impersonation, and when would you use impersonation?
Impersonation can basically provide the functionality of executing something in the context of a different identity, for example assigning an account to users with anonymous access. You would use impersonation in order to access resources on behalf of the user with a different account, that normally, that wouldn’t be able to access or execute something.

• What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?
WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.

• Why are properties important in WebPart development, and how have you exploited them in past development projects? What must each custom property have?
Properties are important because WebParts allow levels of personalization for each user. WebPart properties make it possible for a user to interact, adjust, and increase overall experience value with the programmatic assets that you develop without having the need to use an external editor or right any code. A very simple example of exploiting a property would be something like allowing the user to change the text on the WebPart design interface so that they can display whatever string of text they desire.
Each custom property that you have must have the appropriate get and set accessor methods.

• What are ClassResources? How do you reference and deploy resources with an ASP.NET 2.0 WebPart?
ClassResources are used when inheriting from the SharePoint.WebPart.WebPartPages.WebPart base class, and are defined in the SharePoint solution file as things that should be stored in the wpresources directory on the server. It is a helpful directory to use in order to deploy custom images. In ASP.NET 2.0, typically things such as images are referenced by embedding them as resources within an assembly. The good part about ClassResources is they can help to eliminate recompiles to change small interface adjustments or alterations to external JavaScript files.

• What is a SharePoint Solution File? How does it differ from WebPart .cab files in legacy development? What does it contain?
A SharePoint solution file is essentially a .cabinet file with all a developers ustom componets suffixed with a .wsp extension that aids in deployment. The big difference with SharePoint solution files is is that a solution:
allows deployment to all WFE’s in a farm
is highly manageable from the interface allowing deployment, retraction, and versioning
Can package all types of assets like site definitions, feature definitions (and associated components), Webparts, etc.
Can provide Code Access Security provisioning to avoid GAC deployments
And much more..

• What is a .ddf file and what does it have to do with SharePoint Solution creation?
A .ddf file is a data directive file and is used when building the SharePoint solution bundle specifying the source files and their destination locations. The important thing for someone to understand is that the .ddf file will be passed as a parameter to the MAKECAB utility to orchestrate construction of the SharePoint solution file.

• What file does a SharePoint solution package use to orchestrate (describe) its packaged contents?
The solution Manifest.XML file.

• What deployment mechanism can you use to instigate Code Access Security attributes for your WebParts?
SharePoint solution files can add in order to handle code access security deployment issues. This is done in the element in the SharePoint solution manifest.XML, which makes it easier to get assemblies the appropriate permissions in order to operate in the bin directory of the web application.

• What are event receivers?
Event receivers are classes that inherit from the SpItemEventReciever or SPListEventReciever base class (both of which derive out of the abstract base class SPEventRecieverBase), and provide the option of responding to events as they occur within SharePoint, such as adding an item or deleting an item.

• When would you use an event receiver?
Since event receivers respond to events, you could use a receiver for something as simple as canceling an action, such as deleting a document library by using the Cancel property. This would essentially prevent users from deleting any documents if you wanted to maintain retention of stored data.

• What base class do event receivers inherit from?
Event receivers either inherit from the SPListEventReciever base class or the SPItemEventReciever base class, both which derive from the abstract base class SPEventReceiverBase.

• If I wanted to not allow people to delete documents from a document library, how would I go about it?
You would on the ItemDeleting event set: properties.Cancel= true.

• What is the difference between an asynchronous and synchronous event receivers?
An asynchronous event occurs after an action has taken place, and a synchronous event occurs before an action has take place. For example, an asynchronous event is ItemAdded, and its sister synchronous event is ItemAdding