Tuesday, 25 August 2015

SharePoint 2013 sort Left navigation using jquery

var $eleContainer = $("tr td:last-child.ms-tv-item").closest('div');
var $aryTblChl = $eleContainer.children('table');
$aryTblChl.sort(function (a, b) {
    a = $(a).find("tr td:last-child.ms-tv-item").text();
    b = $(b).find("tr td:last-child.ms-tv-item").text();
    return (a == b) ? 0 : ((a > b) ? 1 : -1);
}); $aryTblChl.detach().appendTo($eleContainer);

Friday, 17 July 2015

Error 545 Error occurred in deployment step 'Recycle IIS Application Pool': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.

while deploying sharepoint solution to the sharepoint environment.


Add user to the sqlserver admins group.
Limit the No of characters entry in textarea control.


function LimitTextAreaContent() {
    $(".clstxtSummary").keydown(function (event) {
        if ($(this).val().trim().length > 500) {
            $(this).val($(this).val().trim().substring(0, 500));
        }
    });
    $(".clstxtJustification").keydown(function (event) {
        if ($(this).val().trim().length > 1000) {
            $(this).val($(this).val().trim().substring(0, 1000));
        }
    });
    $(".clstxtSummary").keyup(function (event) {
        if ($(this).val().trim().length > 500) {
            $(this).val($(this).val().trim().substring(0, 500));
        }
    });
    $(".clstxtJustification").keyup(function (event) {
        if ($(this).val().trim().length > 1000) {
            $(this).val($(this).val().trim().substring(0, 1000));
        }
    });
    $(".clstxtSummary").on('paste', function (event) {
        setTimeout(function () {
            var text = event.currentTarget.value;
            if (event.currentTarget.value.length > 500) {
                event.currentTarget.value = text.substring(0, 500);
            }
        }, 0);
    });
    $(".clstxtJustification").on('paste', function (event) {
        setTimeout(function () {
            var text = event.currentTarget.value;
            if (event.currentTarget.value.length > 1000) {
                event.currentTarget.value = text.substring(0, 1000);
            }
        }, 0);
    });
    (function ($) {
        $("textarea[id$='txtDelegateComments'], textarea[id$='txtComments'] , textarea[id$='txtResubComments'], textarea[id$='txtDCCComments'] ").bind("change keyup input", function () {
            if ($(this).val().trim().length > 250) {
                $(this).val($(this).val().trim().substring(0, 250));
            }
        });

    })(jQuery);
}

$(document).ready(function () {
    LimitTextAreaContent();
});
sharepoint logout of page after every 20 mins using script

var idle = 0;
$(document).ready(function () {
    //Call timeOutCheck every 10 minutes.
    var idleInterval = setInterval(timeOutCheck, 600000); // 10 minute

    //set idlaTimer to true on mouse click/keypress/keydown
    $(this).mousedown(function (e) {
        idle = 1;
    });
    $(this).keypress(function (e) {
        idle = 1;
    });          
    $(this).keydown(function (e) {
        idle = 1;
    });
});

function timeOutCheck() {

   
    if (idle == 0) { // 20 minutes
        window.location.assign(_spPageContextInfo.webAbsoluteUrl+"/_layouts/15/signout.aspx")
        //alert("time out");
    }
    else
    {
        //reset the timer
        idle = 0;
    }
}


Monday, 6 July 2015

calculated column functions
http://blogs.technet.com/b/collaboration/archive/2008/03/28/functions-for-use-in-a-moss-2007-column-today-me-other.aspx

Wednesday, 22 April 2015

Run Javascript from code behid  C# code
 ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('This Document already exists!');", true);

Tuesday, 23 September 2014

Sharepoint resize modal dialog window

 SP.SOD.executeOrDelayUntilScriptLoaded(resizeModalDialog, 'sp.js');
 function resizeModalDialog(){
 var dlg = typeof(SP.UI.ModalDialog.get_childDialog) == "function" ? SP.UI.ModalDialog.get_childDialog() : null;
    if (dlg != null) {
        dlg.autoSize();
}
 }



Modal dialog window

<div class="ms-dlgContent">
    <div class="ms-dlgBorder">
        <div class="ms-dlgTitle"></div>
        <div class="ms-dlgFrameContainer"></div>
    </div>
</div>