SharePoint 2010 compatibility in IE9

SharePoint 2010 is not fully compatible with IE9. To the best of my knowledge this is due to SharePoint’s heavy dependency upon DOM expandos and other features which were available through IE8, but are all removed from IE9. Controls like the Rich TextBox and People Picker tend to render improperly, throw errors on postback, etc. Fortunately, M_Olson posted a JavaScript mod that worked perfectly for me! It looks like this:

function ConvertEntityToSpan(ctx, entity)
{ULSGjk:;    
if(matches[ctx]==null)
	matches[ctx]=new Array();    
var key=entity.getAttribute("Key");    
var displayText=entity.getAttribute("DisplayText");    
var isResolved=entity.getAttribute("IsResolved");    
var description=entity.getAttribute("Description");    
var style='ms-entity-unresolved';    
if(isResolved=='True')
        style='ms-entity-resolved';    
var spandata="";
spandata+="";    
if(PreferContentEditableDiv(ctx))    
{
    if(browseris.safari)        
	{
        spandata+="";        
	}        
	else        
	{
        spandata+="";        
	}    
}    
else    
{
    spandata+="";    
}    
if (browseris.ie8standard)
    spandata+="r";    
if(displayText !='')
    spandata+=STSHtmlEncode(displayText);    
else
    spandata+=STSHtmlEncode(key);    
if (browseris.ie8standard)
    spandata+="rr";    
else    
    spandata+="";    
return spandata;
}
// **** CUSTOM FUNCTION ****
function fixDataInIE9(data)
{    
	if(data.indexOf('') >= 0)    
	{    
		data = data.replace('', '');    
	}    
	return data;
}

Save that as a .js file in your /TEMPLATE/LAYOUTS/1033 path, then reference it at the very bottom of your Master Page, immediately before the two input elements like so:

<script type="text/javascript" src="/_layouts/1033/filename.js"></script>

<input type="text" name="__spText1" title="text" style="display:none;" />
<input type="text" name="__spText2" title="text" style="display:none;" />

Worked like a charm! There are other ways to do this, such as call it from a ScriptLink control, which also works. The key is to load the JavaScript file absolutely last, after all other content has loaded. At least this will give my company the chance to keep using SharePoint 2010 until we can migrate everything to SharePoint 2013.

Eric

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Connecting a SharePoint 2010 List to external database table

I’ve done this plenty of times and never documented it, and one of these times I’m going to be working on something else, have to build one real quick, and forget how I did it, so i’m writing it down.

You can have a SharePoint 2010 List that connects to an external database table and perform CRUD operations on it, and it’s not that difficult to do. There’s generally speaking 3 specific steps required.

First, decide if you want to grant your users of this list database access individually or if you want to use the Secure Store Service in SharePoint. If you plan to grant users individual access to the database resources, just impersonate their credentials when building the External Content Type. In this example, we will use the Secure Store Service.

Open a browser and navigate to your farm’s Central Administration site. Under Application Management, choose Manage Service Applications. Locate the Secure Store Service in the list and click the link to open. In the ribbon at the top, click New.
new sss

The Target Application ID will be a unique name you give that identifies this connection. The Display Name can be any friendly name identifying the connection. The Contact Email should be someone who can administer this connection if there is a problem. Choose Group for the Target Application Type if you plan on granting more than one person access to the list, then click Next.
createnewssapp
On the next screen, you can choose Field Names and Field types. This is how you will be prompted when entering credentials to connect to the database itself. Typically it’s Username and Password, but can be customized to fit your business’s needs.
creds
The next screen requires you to enter Target Application admins and members. The Admins box should be groups or individuals who have admin level rights to the farm. The Members box are the groups and/or individuals who will need access to the resources in the database. NOTE: This is a very specific list, and SharePoint will only allow the people listed in this box to access the data resources, regardless of your SharePoint access. Even if you’re a Farm Admin, you can be denied access to database resources if you’re not listed in this box. Separate multiple users/groups with semicolons.
sssadminms
Once created, check the box next to the newly created item and click the Set Credentials button in the ribbon above
setcredentials
Enter the SQL database username and password that has access in the Username and Password fields. Re-enter the password to confirm and click OK to set the credentials.
entercreds
You now have a Secure Store Application you can use to connect your external database to a SharePoint List!

Second, we need an External Content Type. Open SharePoint Designer 2010 and navigate to the desired site where the list will live. In the left pane, under Site Objects, choose External Content Types, then click the External Content Type button in the ribbon at the top.
external content type
Choose a name for the External Content Type, then click the link next to External System to begin building the connection.
newextcontenttype
In the next screen, click Add Connection near the top
addconnection
You will be prompted to choose the data source type. Choose SQL Server and click OK. Enter the Database Server, the Database Name, and choose “Connect wth Imersonated Custom Identity from the list. Enter the Application ID you created from above and click OK to connect.
connection
Expand out your table listing and locate the table you want to connect to the SharePoint List. Once located, right-click on it and choose Create All Operations
crud
In the next few screen, you set up the Create, Update and Delete (CRUD) operations. It’s best if the table already has a primary key. If it doesn’t, designate a field that could act like a primary key if there were one in the table by highlighting the field and selecting Map to identifier under Properties, then selecting an Identifier in the drop down list. Here you can also decide if any fields are Required, Read Only, change the Display Name of how it will look in the List, etc. Click Finish when done.
parms
Lastly, back in Central Administration, under Manage Applications click Manage Service Applications, then locate the Business Data Connectivity service and click the link. Locate the newly created service, check the box next to it and click Set Object Permissions in the ribbon above
setobjectperms
Enter the names or groups of the individuals who will need access to the database resources in the top box, separated by semicolons, and click Add. Then, for each item, select the item and in the Permissions box below the list of names check the appropriate permissions you want to grant. At a minimum, an average user will need everything but Set Permissions. Do this for every affected user/group and click OK at the bottom.
perms

You now have an External Content Type linked to the database! The only thing remaining is to hook up a list to the External Content Type.

Finally, in SharePoint Designer 2010, on the left under Site Objects choose External Content Type. When the page loads, locate your newly created External Content Type and click it once to select it. Then, in the ribbon at the top choose External List.
newlist
You will be prompted to give the list a name and description. Click OK, and your list will be created automatically!

That’s it, hope this helps!

Eric

Eric Oszakiewski is a professional software developer based in Scottsdale, AZ with over 35 years of IT experience, and 19 years Native American Gaming experience. He is currently working as a Sr .Net/SharePoint Developer for General Motors, and also as a consultant.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube