Category Archives: Uncategorized

Having fun with non-MS tech for person stuck in MS tech for more than decade

I have being experimenting with few non-MS tech just to taste the world out there which I haven’t seen for last decade. I know I’m not going win that world in a day or two, or may be not during rest of my life. But I need to fill-up void in my brain that may open up more happier paths. Specially for a person who code for pleasure.

Pleasure

It is great, when what you do for living also earns you pleasure. I have tasted that pleasure with MS tech for last decade without even at least peeping alien waters of Open Source, or more crowd contributed tech.

So for So good

My love for JavaScript has being one of the key factors made me standout among most of my fellow coders throughout. So started with Javascript’s next big thing Node.JS. Believe me it is fun. I am sure I haven’t felt this way for at least for half a decade since I played with per-release version of ASP.NET MVC.

WOW

this is so easy… click click click with few nexts my Node engine running. Oh no…npm (Node Package Manger) is my best friend now. For some reason, I have never being a fan of Nuget anyway. It is doing everything for me. One highlight is that I couldn’t get away from MS tech fully as I again stuck with Visual Studio Code as the my editor. I tasted Brackets as well.  “forever” got me running all the time even if I crash in the middle.

My love for JS is extended to storage too. With Mongo let me store my JSON without any hassle. Of cause mongoose  giving me helping had in between.

Day dream is over

All of a sudden here I am back in real world seeing some of the things in Node.JS in new .NET word with .net Core.

So all my friends out there like me, try NodeJS, may be Ruby On Rail… believe me will not regret on time spent.

Striping apostrophe from beginning and end of string using JavaScript

For me the JavaScript only provides most primitive set of capabilities that are required by most developers. That is one reason what made jQuery a popular framework. 

To do even simple thing like trimming a sting with a know character is not possible unless you write your own routine. What I have demonstrated here is addition of a function to String type to remove single quotes (an apostrophe) from beginning and end of a string.

String.prototype.unquoted = function (){return this.replace (/(^’)|(‘$)/g, ”)}

var str=”‘hello'”

alert(str.unquoted());

http://jsfiddle.net/oj8jk95s/

Invoke server side code on SharePoint custom ribbon button in background

It is happen to be SP2010 and above not allowing Custom Ribbon Actions not allowed to have ControlAssembly and ControlClass to execute server side code (which happen to be in SP2007).  By the way this is possible with some other locations like context menu even with SP2010.

But there are few workarounds that can make up to this. Three of such workarounds have being clearly showcased by Naddem Yousuf on his blog. However I wanted to have a button which will trigger a update in background while the user remains on the List Form. So I used Nadeem’s 1st option with slight modification to JS event handler. Here is my modification.

    var iframe = document.createElement(“iframe”);
    iframe.setAttribute(“style”, “display:none”);
    iframe.setAttribute(“name”, “hiddeniFrame”);
    document.body.appendChild(iframe);

    var form = document.createElement(“form”);
    form.setAttribute(“method”, “post”);
    form.setAttribute(“action”, pageUrl);
    form.setAttribute(“target”, “hiddeniFrame”);
    document.body.appendChild(form);
    form.submit();

Here I am creating a hidden iframe and using it as the target of the form so that everything from the control response will be hidden from the form.

 

 

“Unable to get property ‘defaultDialogWidth’ of undefined or null reference” on SharePoint Modal Popup

Error message “Unable to get property ‘defaultDialogWidth’ of undefined or null reference ” was thrown when trying to load modal popup on a page where very less of CSOM related script loaded.  In case you haven’t set width or height it is suppose to pick the default value for height and width.  It happens to be all the default values used by most JSOM are loaded from a resource file. 

To be precised, the js library that has the method to load the modal popup  “SP.UI.Dialog.js” has a dependency to the “SP.Res” namespace from where it will pick all the defaults from. 

                                       LoadSodByKey(“sp.res.resx”, function(){
                                          LoadSodByKey(“dialogUI”, function () {

                                            SP.UI.ModalDialog.showModalDialog({url : ‘/sites/abc.aspx’, title: ‘My Page’});         
                                          });
                                        });

Simple but may not be the perfect solution for this it forcefully loading the sp.res.resx resource file content with “LoadSodByKey”.

 

My second attempt to getting into blogging

This is my second attempt to getting into blogging which I wanted to be in for many years.  I had this feeling for so many years just because I have been heavily depending on knowledge shared by many others through there respected blogs and I just want to do the same.

Hopefully I can also contribute to the world with something ….I mean some knowledge that I have as a human….