Creating a custom Virtual Earth Web Part in SharePoint 2010

I had a requirement to create a web part that will pull the address information from one of the records in CRM and show it on the map.

One of the issues I faced while trying out different approaches was that after adding the web part to the SharePoint page, the scrollbar used to go missing in that page.

Finally with help of below two links I managed to develop a the web part.

Well we could make use of the below code to achieve that

public class MyVirtualEarthWebPart : WebPart
protected override void OnLoad(EventArgs e)
System.Web.UI.ClientScriptManager csm = Page.ClientScript;
StringBuilder builder = new StringBuilder();
string SCRIPT_NAME = "MapScript" + this.ID;

builder.Append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n");
builder.Append("<script type=\"text/javascript\" src=\"\"></script> \n");
builder.Append("<script type=\"text/javascript\"> \n");
builder.Append("    var map = null; \n");
builder.Append("    var latitude = null; \n");
builder.Append("    var longitude = null; \n");
builder.Append("    var address = ''; \n");
builder.Append("    var titles = new Array(); \n");

builder.Append("    function GetMap() \n");
builder.Append("    { \n");
builder.Append("        try  \n");
builder.Append("        { \n");
builder.Append("            address = 'New C G Road, chandkheda, gandhinagar';\n");
builder.Append("            map = new VEMap('myMap');\n");
builder.Append("            map.LoadMap(null,4,VEMapStyle.Hybrid); \n");
builder.Append("            map.Find(null,address,null,null,0,10,true,true,true,true,FindCallBack); \n");
builder.Append("        } \n");
builder.Append("        catch (e) \n");
builder.Append("        { \n");
builder.Append("            alert('GetMap: ' + e.message); \n");
builder.Append("        } \n");
builder.Append("    } \n");

builder.Append("    function FindCallBack(shapeLayer, results, positions, moreResults, e) \n");
builder.Append("    { \n");
builder.Append("        try  \n");
builder.Append("        { \n");
builder.Append("             if(positions != null && positions.length > 0) \n");
builder.Append("              { \n");
builder.Append("                PlacePushPin(positions[0].LatLong.Latitude,positions[0].LatLong.Longitude); \n");
builder.Append("                latitude = positions[0].LatLong.Latitude; \n");
builder.Append("                longitude = positions[0].LatLong.Longitude; \n");
builder.Append("               } \n");
builder.Append("        } catch (e) { \n");
builder.Append("            alert('FindCallBack: ' + e.message); \n");
builder.Append("        } \n");
builder.Append("      }      \n");

builder.Append("    function PlacePushPin(lat, lon){ \n");
builder.Append("                latlong = new VELatLong(lat,lon); \n");
builder.Append("                customerPushPin = new VEShape(VEShapeType.Pushpin,latlong); \n");
builder.Append("                customerPushPin.SetTitle(address); \n");
builder.Append("                map.AddShape(customerPushPin); \n");
builder.Append("                map.SetCenterAndZoom(latlong,15);  \n");
builder.Append("                } \n");

builder.Append("_spBodyOnLoadFunctionNames.push('GetMap'); \n</script> \n");

protected override void CreateChildControls()
StringBuilder builder = new StringBuilder();
builder.Append("<div id='myMap' style='position: relative; width: 300px; height: 300px;'></div>");
this.Controls.Add(new LiteralControl(builder.ToString()));


SPUpgradeException Exception message: An error has occurred on the server.

Hi I got the error while trying to open the SharePoint Site after applying the MOSS SP2 update to it.

This post was helpful in resolving that error

  • Nachrichten dieses Autors suchen

    Hi Guys

    I had the same problem. and i fixed it by going here…

    download the file that matches your OS. ie x32 or x64
    If you try to run the file it will tell you the patch is already installed.
    but run the file with “/extract” extrace the file to someware and run
    Let it do its thing. It takes a while……Then presto. well as least for

    Let me know how you guys go with it.

    Hope it helps!

Exception: Microsoft.SharePoint.Upgrade.SPUpgradeException: Sequence [Microsoft.SharePoint.Upgrade.SPConfigurationDatabaseSequence] cannot upgrade an object [SPConfigurationDatabase Name=””] whose build version [] is too old. Upgrade requires [] or higher.

Hi I got the error while trying to upgrade MOSS 2007 Content Database to SharePoint 2010.

The reason was the update requires that MOSS 2007 has the SP2 applied to it.

Check out this extremely helpful post


Customizing NewForm.aspx and EditForm.aspx pages for Lists.

Recently, I was assigned a task to customize the NewForm.aspx and EditForm.aspx for a particular list. The list was part of a site definition generated using SharePoint Solution Generator.

The reason we wanted to customize the page was because we wanted one custom field to be added (drop down list) that would display all the content types in that site.

You can find the sample project and related files over here


Please rename the file from SharePointProject.doc to after downloading it.


LookUp for Site Definition in SharePoint.

Suppose we have created a site definition for an existing Site having two lists and one of the lists uses a lookup column that points to the other list.

Now if we are creating site using that site definition we will find our lookup column missing in the list.

If we check the schema.xml for our list, we will find our lookup field to be commented.


To get it working ,  we need to define the field in the following manner


<Field Type="Lookup" DisplayName="myLookUp" Required="FALSE" List="{72424dd2-9030-408a-97c9-8482d9d81204}" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE" ID="{f50277a0-4da5-46d3-8e60-284c729a3eb8}" SourceID="{07e7832d-45df-4f69-b5bb-e31c5107c5ca}" StaticName="myLookUp" Name="myLookUp" ColName="int1" RowOrdinal="0" />

It should be modified to

<Field Type="Lookup"
StaticName="myLookUp" Name="myLookUp" ></Field>

SecondList :- The name of the other list.

Check this wonderful post



Invalid data has been used to update the list item. The field you are trying to update may be read only.

I got this error while updating an splistitem. It was coming while trying to update “Person or Group” type column.

This is the correct way to update the column of type “Person or Group”.

itemApprovalAssignment["Title"] = txtTitle.Text.Trim();
                    itemApprovalAssignment["Assign_x0020_To"] = oweb.EnsureUser(peAssignTo.CommaSeparatedAccounts);

i.e. to use EnsureUser method.