TinyMCE validation with MVC

Today I am trying to figure out how to do validation with TinyMCE editors while using MVC’ s unobtrusive validation.  I did a google search and came up with a large number of results that all said the same thing.  I couldn’t get any of them to work.  While testing I found the following solution.  It isn’t perfect but is pretty close to what I need.

Here is the solution I came up with. I didn’t need to add any other additional code to the page.

      $('form button[type=submit]').not('.cancel').click(function () {
        var form = $('#FormName');
        var isValid = form.valid();
        var istinymceValid = $('#ContentField').valid();
        if (!isValid || !istinymceValid) {
          return false;
        }
        return true;
      });

Bootstrap3 Dialog

Bootstrap3dialog

One of the great things about programming in the world today is that so much of the basic functionality I need can be found somewhere on the Web, as long as you know the correct search string.

I spent a good chunk of time looking for a quick and easy way to use Bootstrap modals without having a ton of ugly code on each page that isn’t really necessary.  Especially for modals that are repeated throughout the software.

This time I was looking for a Bootstrap modal that could be easily used for Alert and Confirmation boxes.  I couldn’t find one out there, even though I knew it should exist, so I built my own.  Then I plugged in a different search string and found exactly what I needed.

Bootstrap3 Dialog (Git Hub)is a nice clean simple solution that meets all our needs.  The code is well laid out and I was able to make some minor modifications that met our custom needs.

#VisualStudio Shortcut Keys – Open File in Solution Explorer

Solution-ExplorerWhen working in an application as complex as Visual Studio it becomes necessary to learn the shortcut keys.  Some of them are used so much that the keys get hit with no thought at all.  Then there are those few that are necessary for doing things, like efficient navigation of large projects, but are used so rarely that they are easily forgotten.  One of these is the “Sync With Active Document” (Ctrl+[, S) command.  Opens the Solution Explorer and navigates directly to the file that you are looking at.

 

screenshot-navigate

Visual Studio: Navigating large files

I am often working in Visual Studio in Controllers that have a large amount of code in them and want to look at code from multiple parts of the file. Using the split screen view is not sufficient.  The following is how I maximize my monitor space to get the best experience with the fewest distractions.

1. Select the tab you are working with.
2. Select Window -> New Window
3. Select Window -> New Vertical Tab Group
4. Press Shift – Alt – Enter to switch to full screen mode.

Lazy Programming: The Three Virtues

Three Virtues

According to Larry Wall, the original author of the Perl
programming language, there are three great virtues of a programmer; Laziness, Impatience and Hubris

  1. Laziness: The quality that makes you go to great effort to
    reduce overall energy expenditure. It makes you write labor-saving
    programs that other people will find useful and document what you
    wrote so you don’t have to answer so many questions about it.
  2. Impatience: The anger you feel when the computer is being
    lazy. This makes you write programs that don’t just react to your
    needs, but actually anticipate them. Or at least pretend to.
  3. Hubris: The quality that makes you write (and maintain)
    programs that other people won’t want to say bad things about.

via Laziness Impatience Hubris.