Style Promoted Links in your SharePoint site

I had a colleague that wanted to use the Promoted Links webpart on his site as a navigation tool, but he wanted it to display vertically instead of horizontally. So I did some digging around.

http://social.technet.microsoft.com/wiki/contents/articles/26522.everything-about-promoted-links-in-sharepoint-2013-change-size-wrap-view-handle-click-event-using-jquery.aspx

Fantastic article!! In minutes, using the tips in this article I was able to make the tiles appear vertically as well as being able to make them appear in rows. I could also resize the tiles, getting exactly the look that I wanted. Check it out and try it for yourself!

Posted in General SharePoint, SharePoint Coding, Web Parts | Leave a comment

How to redirect as page on SharePoint Online (Office 365)

Here’s a common scenario. You’ve created a site in SharePoint and have business users going to it. You know they’ve bookmarked the site. Then, having learned some lessons and new tricks along the way, you create a new and improved site and want people to start going there instead. How to communicate? How can you catch all?

Enter the redirect. It tells the browser, no, don’t go here. You actually need to go there. How can we do this?

Well, it turns out to be incredibly simple (for this use case anyway – there are other scenarios where this solution isn’t a good fit). Go to the page that you want redirected and edit it. Put a script editor web part on the page (found in the content and media group). Click edit snippet. Put in the following:

<script type=”text/javascript”>
<!–
window.location=”http://<address of the new and improved site>”
//–>
</script>

And that’s all there is to it. When I come to the old page, I will be redirected to the new and improved. How easy is that?!

What if I make a mistake and did a typo on the location? Well, that seems like it is a really sucky place to be. When you try going to the page to fix it, before you can stop it, you are redirected to the error message saying page does not exist (or whatever depending on the typo or mistake that you made). So how can I fix the page? This also turns out to be very simple. Type in the url to the page that the redirector is on but follow it with “?Contents=1″ and that will take you to a page where you can delete the script editor. Then you can edit the page again, adding the script editor and this time getting the url right! :-)

These are two valuable tricks that I am awfully glad to have in my toolbox. Special thanks to my friend Kimmo Forss for showing me both of these tricks!!!

Posted in General SharePoint, Web Parts | Leave a comment

What makes a great boss?

Here is another very interesting article that I read on the subject o f being a great leader: https://www.linkedin.com/pulse/9-hidden-qualities-only-exceptional-bosses-possess-jeff-haden?trk=pulse-det-nav_art

The author hits some very key points. A lot of it goes back to trust and credibility. As a boss/manager/leader, what is and what is perceived about you? Do you genuinely care and listen to your team? Do you allow them to grow, learning lessons along their progression? Do you seek to understand the why behind actions or simply try to cover things over?

These are the things that separate people who want the “glory and power” of being a manager from the people who strive to be great leaders. Leaders are about the team and not just themselves.

They [great bosses] feel supporting their employees — even if that shines a negative spotlight on themselves — is the right thing to do and is therefore unremarkable.

One of the great points, for me, that was made in this article is that great bosses do not see control as a reward. I had never thought about it from this perspective, but it is so true. People that want to become a manager because they deserve the control and are going to make things right are rarely good managers. Their motivation is in the wrong place. Being a great manager is about wanting to support your team not control them. It’s about nurturing and guiding. It’s making the time and effort to commit to individual’s development, hopefully in alignment with the company’s greater good.

To be a truly exceptional leader is to be selfless.

That’s why there are so few.

Posted in Knowledge Management, Religion/ Philosophy, Social commentary | Leave a comment

Relax.

We’ve all been there – both as the sayer and as the receiver. You are stressed out over something and someone says “Relax”. How does that make you feel? Why do we respond to that word that way?

Brian De Haaff, CEO of aha!, shared his thoughts in a very insightful posting on LinkedIn. You can read it at https://www.linkedin.com/pulse/one-lie-deceptive-leaders-tell-brian-de-haaff?trk=pulse-det-nav_art

One of the points that he makes, for me, was particularly poignant; great leaders are immersed in the moment when they are most needed. It sounds simple and even trivial. But think about it for a moment. Have you ever had a manager that never seemed really connected to you? A manager that only reflected on their own image and did not hear you? How effective were they? To be a leader, during times of difficulty and stress, one has to be in the moment, experiencing what others are going through and empathizing. Only then can a leader effectively guide a person or team through the situation.

Thanks Brian for sharing!!

Posted in Knowledge Management, Religion/ Philosophy, Social commentary | Leave a comment

The Importance of Culture

Those who know me will not be surprised when I say that culture is everything. Culture effects every aspect of our lives, both personal and business. And it crosses those boundaries.

Here is an interesting article to demonstrate:

http://www.computerworld.com/article/2851974/microsoft-study-finds-everybody-wants-devops-but-culture-is-a-challenge.html

Posted in Knowledge Management | 1 Comment

Testing for NaN

I was in the middle of building a Windows Phone 8 application when I ran into an interesting problem. My application tracks where the phone is and uses it as the center point on the map that is being displayed. I wanted the map to be adjust its heading to match the direction that the phone (user) is heading. It seemed simple enough. The Geolocator PositionChanged event passes into the handler “PositionChangedEventArgs”. The args then has a property of Position.Coordinate.Heading that is of type double?. The ? part of the type indicates that it is nullable. When it is null it comes back as NaN (not a number). No, problem (I thought). I’ll just do a check like this:

if(args.Position.Coordinate.Heading != null) …

But it always returned True. So I tried:

if(args.Position.Coordinate.Heading != Double.NaN) …

But it always returned True. Well, for reasons I won’t get into here, even if you do the following check it will always return false: Double.NaN == Double.NaN

But, I found a sneaky way (reading specifications is so helpful!) around the problem. It turns out there is a CompareTo method on the Double.NaN. If the value you are comparing is indeed a NaN, then the return value will be 0. If it returns 1 or -1, then the result is indeed a number. So, I changed my implementation to include the following:

double? tmp = args.Position.Coordinate.Heading;

            if (Double.NaN.CompareTo(tmp) != 0) …

And that seemed to do the trick. Hope this is helpful to you!

Posted in C# Programming | Leave a comment

Pagination in ASP.Net MVC

I’ve been working on a project using MVC (my first real go around) with Entity Framework providing my model. I’ve been learning a ton of little tricks and I figured I’d better start capturing them now before I lose them or forget. Then 6 months from now I’ll be going, “now where did I have that code that…” LOL

So, to facilitate my own learning curve, I build a very simply database to track my music of interest. I have a table for songs, albums and artists. When displaying Artists, I found that I wanted pagination on the page. I started looking around on the web and found there are tons of different ways of doing it, many that did not make sense to me and none that I tried that actually worked. Therefore, I began working it myself. Here’s how I did it. In the ArtistController (I’ll be doing other posts to explain MVC – if this doesn’t make sense now my apologies. I am handling this topic in a little bit of a scattered way) I added the following Action:

        public ActionResult Paged(int page, int pagesize = 5)
        {
            ViewBag.Page = page;
            ViewBag.PageSize = pagesize;

            int skip = (page - 1) * pagesize;

            var artists = db.Artists
                .OrderBy(c => c.ArtistName)
                .Skip(skip).Take(pagesize);
            return View(artists.ToList());
        }

You can see that this Action takes two parameters, both int. One that represents what page you are on (page) and how many entries are on a page (pagesize). So a 5 and 10 means go to the fifth page where there are ten artists on each page. I pass these values to the ViewBag so I can reference them in the View. I then calculate how far to skip ahead in the model (skip = (page-1)*pagesize). I then use the LINQ statement that says use the Artist model (db represents my EF model with Artists being a class within that model), ordering by artist’s name but that skips the first ‘skip’ artists and takes the next ‘pagesize’ after that. When this LINQ query executes, it will get the artists that I am looking for based on the pagination data provided. Simple right?

Then, in the view that this Action brings up, I used basically the same View that I did for the default Index View and Controller, but I demonstrate how the ViewBag facilitates the exchange of information (i.e. what page the user is on and how many are on a page):

<p>
    On page @ViewBag.Page with a page size of @ViewBag.PageSize.
</p>

My MVC is using the RAZOR engine, making the use of the ViewBag so simple. All that is left (which I haven’t done yet, but will update with when complete) is to build a nice looking control to facilitate the visualization of the paging and including links to flip back and forth on pages like you see in most web apps. The URL to call say the 3rd page of Artists when we are viewing 10 Artists per page looks like:  http://localhost:5027/Artist/Paged/x?page=3&pagesize=10  Artist is the name of my controller. Paged in the Action defined above. And the rest is simply putting the data into the query string. Easy right?  :-)

More to come, but I wanted to document this while I am on it. I’ll be hitting some of the basics and some of the little nuances that I pick up along the way. I’ve found that the tutorials out there (especially those provided by Microsoft) do an excellent job of showing the basics and the norms. But when do our projects stick to the simple and norms? ;-)  So I will document some of those other cases in my blog. Hope this helps!

[Updated]

I continued adding features to my paging solution. It turned out to be very easy to do. Most of the solution I saw online were complicated and required third party tools or JavaScript libraries.  My personal thoughts (and feel free to make a case if you think I am mistaken) that using JavaScript to handle paging is counter productive. JavaScript executes client side – why bring too much data to handle over to the client side only to scope it there? Why not let server side dish up the appropriate amount of data? So that’s the approach that I took.

First, one think for me that made the other posts online difficult to follow was the ordering of items. In order to do paging, you have to touch the controller and the view at different points. In cases like these, a picture is worth a thousand words to me. So, to be helpful, here is a picture of the interconnections:

Image of controller and view

Controller and View – click to see larger and clearer

The controller is our starting point for this discussion. The user has come to the controller by entering the appropriate url or through navigations you have provided. The key is the method that it comes to returns an ActionResult. This points the user to the View intended. So we are now off to the View. Inside the view, you may need to facilitate some interaction with the user. For this example, I wanted the user to be able to pick how many log entries were being displayed on the page at a time (hence paging). Now, this selection doesn’t have anything to do with the data model (I am using Entity Framework for this application – if you haven’t used EF, check it out! It is really a great piece of technology. Extremely robust and fun to use! Powerful while being a logical abstraction.) so I really don’t want to cross concerns and implement a page size concept in my model.

What’s needed is a simple HTML form. Notice in the diagram, I have some of the HTML of the View shown. There is a HTML form that contains:

Html.BeginForm("ChosePageSize""CentralLog"FormMethod.Get)

This forms contains a drop down list that enables the user to select pre-fixed page sizes. The first parameter is a string of ChosePageSize. This is the critical part to understand. That string is the name of the method back in the controller that will be called when this form is submitted. The data collected in this form is then available to the controller. Let’s look at the ChosePageSize method in a little detail.

(more coming)

Posted in Entity Framework, Model View Controller (MVC) | Tagged | Leave a comment