mardi 15 mai 2012

How to find sharepoint list schema

The url to see any list schema is:

http://yourserveradress/_vti_bin/owssvr.dll?Cmd=ExportList&List={LISTGUID}

To have the list guid, go to the list page and click List Settings, look to the url and you will find the guid list as value of the 'list' querystring.

lundi 14 mai 2012

How to enable styles and markup styles in richtext field in List Sharepoint 2010

The styles are disabled because in sharepoint 2010 the styles and the markup styles menus are exclusive to wiki pages.





To fix this problem you will have to change your field in the schema.xml like this

<Field ID="{BF6BD5D0-F44A-4B62-99D7-A92A1465DFBF}"
         Name="RichtextMenuEnabled"
         DisplayName=" RichtextMenuEnabled "
         Type="HTML"
         RichText="TRUE"
         RichTextMode="ThemeHtml" />
and you will have the same field without having to delete/Create the list with the menu enabled

Hope that it helps if not please post a comment

mardi 8 mai 2012

Sharepoint 2010: Add New Item Button In AssetPortalBrowser

Hi,
Adding new item from AssetPickerBrowser was possible in Sharepoint 2007 but in sharepoint 2010 Microsoft has disabled this functionnality due to placing this action in the Ribbon.
Here i post a customized version of assetpickerbrowser with this functionnality unabled.
It's simple, i just had to add a simple script in the head.
First of all Edit C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\AssetPortalBrowser.aspx as Administrator
and copy/paste this script in the PlaceHolderDialogBodyHeaderSection placeholder

<!-- Custom code start here-->
<!-- Customized By Safouene, safouenehaj@gmail.com for support or if you can optimize this version--> 
<script type="text/ecmascript">

    var options;
    function openModalDialog(pageToCall) {
        options = SP.UI.$create_DialogOptions();
        options.width = 700;
        options.height =500;
        options.url = SP.Utilities.Utility.getLayoutsPageUrl(pageToCall );
        options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
        SP.UI.ModalDialog.showModalDialog(options);

    }

    function CloseCallback(result, target) {
        location.reload(true);
    }

</script>
<script>
function querySt(ji) {
            hu = window.location.search.substring(1);
            gy = hu.split("&");
            for (i = 0; i < gy.length; i++) {
                ft = gy[i].split("=");
                if (ft[0] == ji) {
                    return ft[1];
                }
            }
        }
function insertBtnCustomUpload()
{
var queryListId = querySt('List');
var queryRoot = querySt('RootFolder');
if(typeof(queryRoot) == 'undefined')
{
queryRoot = '';
}
if (queryListId != null && queryListId.length > 0) {
var goToUploadUrl = "Upload.aspx?"+ "List="+queryListId+"&RootFolder="+queryRoot +"&IsDlg=1";
document.getElementById('DeveloperDashboard').innerHTML = "<a href=\"javascript:openModalDialog('"+goToUploadUrl+"');\" style='float:right;color:#3966BF;margin-right: 10px;margin-top: -20px;'>Add New Item</a>";
        }
}
</script>
<!-- Custom code ends here -->
in the code of the javascript function_spBodyOnLoad() add this line as last line
insertBtnCustomUpload();

save.
Now try it and you will see an 'Add New Item' link appear when you open a document Library.
Clicking in this link, an upload popup will open like the open that we have in the document library, i am very satisfied of what i've done, it's like it was given by microsoft by default. Enjoy :)
In this version also, using Chrome or firefox, the popup will do an auto-postback after the upload and then you will see the new document added (IE not, because in IE the popup doesn't do a postback).
This version is very useful for urlpicker, it works like a charm
copy and paste it in.

samedi 7 janvier 2012

How To Write Month In Custom Language

It's so much simple
For example for French Language:
CultureInfo culture = new CultureInfo("fr-FR");
string month = culture.DateTimeFormat.GetMonthName(DateTime.Now.Month);