Tuesday, March 06, 2018

Coda Obsura: Getting the selected items of a Telerik Kendo ListBox.

Maybe I'm missing something.  But I don't see any javascript API for getting the SELECTED items in a kendo listbox.  I'm just binding to a string list that I pull with a read.  I ended up having to get the items using jquery hunting them down by the selected style.

  $('#mylistboxname').prev("div").find('ul').find('.k-state-selected').each(function () {

Tuesday, January 30, 2018

Adding to, and Accessing, Properties on the ApplicationUser Class in ASP.Net Core 2.0 MVC

Ok, this is actually really simple to do, but frack me if it didn't take me awhile to figure things out.  Note for this example we will use a code first approach just to show the concept.

Step 0: Create a new core MVC project, select the option for authentication called something like "store credentials in application" (I'm updating VS Studio right now so going on memory).

Step 1: Add whatever properties you want to the ApplicationUser class, stuff like

public string SomeField {get; set;}
public string SomeOtherField {get;set}


Step 2: from the nuget console, run add-migration , give it a name.

Step 3: from the nuget console, run update-database

When done you can use whatever to see the table with the new fields (In VS sql server object explorer).

Optional: You can tweak all the view and manage models to support your new fields.  I didn't for now.  I just went in and gave one of my new fields a value.

Step 4: Tweak you controller and inject the usermanager into your controller.
a) include using Microsoft.AspNetCore.Identity; and maybe the namespace of where you models reside.

b) Add a private usermanager variable to your controller like so-

    private readonly UserManager _userManager;

c) Then on your initialization method, inject the usermanager.  If your controller is names HomeController it would look like this-

public HomeController ( UserManager userManager )
      _userManager = userManager;

Step 5: In your controller you can now access the added properties to your user like so (in this example I added PersWeboptionsText to the field  ApplicationUser class.

  // test for a given value...
      var weboption = _userManager.GetUserAsync( User ).Result?.PersWeboptionsText;

YAY!  Now you can use and abuse that value to do whatever.

But what about in a view?  Are we stuck always passing that value in as ViewData or something?  No, you can use a similar approach.  You must inject the user manager into your view (or into your _layout.cshtml file at the top like of the view like so-

@inject UserManager UserManager

Ok, now in your page to access customer ApplicationUser properties/fields, again using PersWeboptionsText as an example field added to ApplicationUser, you can do so like this-

@UserManager.GetUserAsync( User ).Result?.PersWeboptionsText

That should get you going.  Next up is adding collections to the ApplicationUser and making sure they populate right.

I should come back and reformat this post and make it pretty...ain't nobody got time for that.

Happy Coding.

Friday, December 01, 2017

Using Thor's Hammer to Crush a Tac into Cardboard

All right, not so much of a techie article, more of a choice / philosophy article.  Here goes.

Back in the late 90ies, when this thing called the interwebs was just getting going, there were all sorts of smaller software packages you could buy to do little things.  Ulead GIF animator, 3DFX suite, Bryce 3D, gosh I forget most of them at this point which makes me sad.  I didn't have a lot of money back then (still don't but relatively I'm more able to purchase things).  I loved saving my pennies and buying these little 50 dollar software packages that would allow you to do photo editing and basic 3D stuff.

But the big stuff, like Photoshop, was always out of reach to me.  So I went on this thing called usenet (ancient I know) and there was a adobe.support.whatever group.  I didn't have much money, but I worked at a winery at the time, and I could get wine dirt cheap, so I figured maybe I could reach out to Adobe and make a deal.  And it worked.  Pretty soon I exchanged emails with someone at Adobe and traded a box of various wines for a brand new version of Photoshop 4.

Now I was professional.  I loved that program and played with it a lot.  But over the years I went more of the programming route, and had less and less time to play with Photoshop.  Somewhere around version CC whatever the interface changed quite a bit.  I find sometimes with the new interface doing simple stuff takes me a bit to figure out.  If I still used Photoshop often it would be no big deal, but the truth is I just don't anymore.  And what I do use it for is often really simple, stuff free software could like Paint.Net could do really easily.

So it leaves me with a conundrum.  I've been fiercely loyal to Adobe ever since I traded with that one guy online for a case of wine for Photoshop.  I love Adobe products.  I pay for the full creative cloud (about 55 to 60 bucks a month) which gives me everything.  After Effects, Premier, the works.  And for all you get that price point in my humble opinion is an absolute bargain...if you use the tools a lot.

And there is the rub.  I don't.  I want to.  I keep setting little goals for myself to learn After Effects or Indesign.  If I don't I will give up the subscription.  The goals come and go but yet over 600 bucks a year goes out of my wallet to Adobe.

Two issues.  Expense and learning curve.  GIMP, Paint.Net, Paintshop Pro, etc... are all fairly capable programs for what I would ever use them for.  These low end "consumer grade" or freeware stuff has come a long, long way from where they were ten years ago.  Paintshop Pro is fairly compatible with Photoshop, I think it can even export PSD's and such.  Premier is awesome, but I haven't really used it since like CS1, and when I try to use it now I can figure stuff out, but it takes awhile.

There is a sale going on right now where I can get Corel's Paintshop Pro and whatever the Video Editor is called for like 80 bucks.  I've used Vegas (competing video editor to Premier and another tempting but more expensive option) before and I like it, but that Corel bundle is tempting.  About a month and a half of what I pay for Adobe's stuff.  Hell I could even buy the latest versions every year and still come out way ahead.

 I think I'm going to give up my subscription, and because of my history with Adobe it sucks.  I hesitate a bit because in a sense it is admitting defeat for me.  By giving up on the professional grade Adobe tools I am admitting to myself that I most likely will never become a professional graphic designer.  When I initially got into web development, twenty years ago, the graphic side of things is what I liked.  But I realized quickly that my talent there was limited, and focused more on coding.  That little bit of that young man getting into tech still lives and still really wants to be a "real" graphic designer, but...the reality of things is I just won't get, or make, the time to do it, nor encounter projects both at work and at home that really push me on the graphic design level.  I sadly am coming to grips with this, and thus I'm more willing to give up my Adobe subscription for the "consumer" grade stuff.  It bums me out.

But at the same time, using newer, less clunky software might actually be a key to jump starting my graphic design skills again.  With limited time, using easy to (re)learn stuff to get content out the door quickly when I do have time to play with things just might be the spark I need.  Instead of using a giant hammer to tackle a simple task, which makes the task less fun, maybe using a simple, quick, light tool to do it will get me past those simple task into more complex ones, where I actually do hit a wall and need more advanced tools to get a job done.  And if I can convince my wife to let me keep that 600 dollar yearly budget, but spend it on other things, I can purchase some 3D software I've been eyeing again.

Lastly, Adobe has changed a bit from when I first had a relationship with them.  It seems Adobe, even though their tools are still absolutely the best, is a different company now then when the were in the 90ies.  As a company they have blown a few opportunities as well.  Director could be eating Unity's lunch, but Adobe let the ball fall there.  Not sure Flash was handled like it could have been as well, heck I would have rather have seen Director pushed more than Flash.  And then when Adobe did redo Directory they just outsourced to a team of programmers and did a refresh.  Not sure how much in house talent they keep around in house.  I'm sure some, but they are doing the global outsourcing thing like everyone else.  No longer the slightly bigger Mom and Pop company that I encountered long ago.  Maybe my out for a little disloyalty :)

Well, if I ever am able to get into the swing of things, I can resubscribe I guess.  Just worry I never will as time and tide take me down other paths with software.  But the option is there.

Adobe, I love you.  Your software is still king.  But I must acknowledge that a full on graphic designer I am not, and I can make do with a lot less.  Makes me sad.  It is me not you.

Monday, November 20, 2017

Firefox's Quantum and SQLite Manager

Well, our beloved SQLite Manager, along with a whole host of extensions,  is no longer compatible with Firefox Quantum.  I guess there is an "extended" release for Firefox that supports older extensions, so there is that way to go.  A possible alternative non-extension for SQLite Manager may be found here-


I haven't had a chance to play with it much, but I remember bookmarking/favoriting this program awhile back thinking it looked about as good as SQLite Manager.

Give it a whirl and tell me what you think.

Friday, November 10, 2017


A former boss of mine, a great guy, made a comment about some code I wrote a long time ago and how the follow on developer said it was crap.  Oh I betcha it probably was...some of the stuff I still right today is crap.  I just wrote some crap a minute ago.

Crap code sometimes is a value add.  Craftsmen like to do everything perfectly.  But sometimes when someone needs a hammer you don't need to always build Thor's Hammer for them.  Sometimes if someone brings in something broken fixing it with duct tape works fine.  Not always, but sometimes. I know even thinking this way is heresy in the current world of code blogging.  But writing code is only a single domain.  Problems often are multi domain problems, where time, effort, and other priorities play a roll.  Sometimes you just have to do what you can and move on though I agree that this shouldn't be done just for laziness sake (though I'm guilty of this a time or two).  People following after you may not know the variables at play.  All they see is a crappy hammer and some duct tape.

A prime example of this.  I'm working on a big project, but I get pulled off to do a minor upgrade on an older project.  I look at it.  To do this upgrade the proper way would have required re-writing code that affected a whole lot more than just the minor update I needed to accomplish.  Plus, I'm having a feeling that this project within a few years will be rewritten from the bottom up.  So, I decide to just "hack" it for now so I can get back to other priorities, so I don't have to rework something that goes deep into the code base that could have unintended consequences, and I won't have to spend time to do more testing than either the project manager who pulled me off another bigger priority or myself originally thought.  The "hack" took about a half an hour and 15 minutes of testing.  Done.  Moving on.  In a few years I might come back and look at what I did and say "what the frack?"  But EVEN if I did do the deep fix, I guarantee  when I rewrite the application (or whoever else does) this code section will be completely rewritten from the bottom up as requirements over time have changed and will change.  So it would have been pure vanity as a craftsman to "do it right" this time around.  I left a few notes and called it good.

And I've inherited lot's of code over the years that I would have written differently if I wrote it.  I would have written it "better" or at least more understandable.  But I don't remember ever calling code that worked crap.  But then that is how I judge things...does it work?  Do the users like it?  Is it responsive?  Are there at least a few things I'm wowed a little by?  If yes then I call what I wrote or anyone else wrote a success.

In the instance I was critiqued on,  I know my code worked, just some anal type didn't like how I wrote it.  I also know that an auditor for the fortune 500 company I wrote it for called it one of the most intuitive tools he ever used.  And he didn't say this to flatter me as I was already gone from the company, he said this after.  So suck it anal type!

Now the kicker.  As a developer I'd say I'm mediocre. I've met many developers who can program rings around me.  I've also met many who cannot (some may know this, many may not, but proof is in the pudding).   I'm not the best craftsman nor, to be totally honest, do I want to be.  The problems I'm solving are often more interesting to me then the tools being used to solve them I guess.  But I get the job done.  The average burn out rate for a developer is five years...I know many great developers who have lasted longer than that, but that is the average.

So I wonder, I'm still here.  I've been writing code, some good, some bad, most mediocre, a small percentage brilliant, for almost 20 years now.  Many craftsmen would hate me.  I betcha I'm sill here after they have burned themselves out and are gone...

I guess that comment just stung more than it should have.  And I also have to keep in mind that much of my success has been due to grace...unmerited favor by the creator Jesus.  I've gotten opportunities that I didn't merit and advanced in my career beyond what others more talented then myself have been able to.  I don't want to get a big head.

But to distractors,  although it might aggravate you, I'm still here...while most of you are gone gone gone!

Tuesday, May 16, 2017

Microsoft is Losing Me

Firstly, Microsoft has been good to me.  My semi-mastery of Microsoft tools for web development has spawned nearly a 20 year career.  So I am by far not a Microsoft hater.  Yet some recent things that Microsoft is doing has me scratching my head.

  • ASP.Net Core - The idea of having one framework that will run nearly anywhere is a noble one.  But is this really a problem that your average enterprise development team was asking to be solved?  Most (I'm guessing) that use Microsoft Visual Studio for development are solidly in the Microsoft ecosystem.  The idea of running MVC on non-Microsoft servers appeals to what...one percent of the Microsoft ecosystem users?  Plus if I can use free tools to develop open source MVC say, why would I be paying 1000's per year per developer seat for Visual Studio? So I can tweak JSON config files and run things from the command line out of penis envy for Linux users?  Dude I like GUI's.  Seems I'm one of the few.  Maybe that makes me a weak programmer but I grow tired of coda obscura for config files and other command line crap.  Give me a limited set of options in a GUI window that is well documented so I can pick what I need and move on to solving problems not pulling my hair out with being gifted with additional ones from Microsoft.
  • Along similar lines, what is up with XAML?  I knew Silverlight would fail just like few are picking up XAML.  Again, why the GUI hatred all of a sudden?  Weird.
  • Constantly changing things.  We have been jumping through hoops from Microsoft for years.  First ASP.  Then ASP.Net Webforms.  Then MVC.  Now MVC core with helper tags quasi bringing back webform like functionality  (but without the GUI support...sigh).  As we jump through the hoops we leave a scattering of legacy applications behind us.  The bleeding edge buzz word flinging developers build and move on leaving their head aches to others while they pursue fame and glory.  Us rank and file dudes have all these apps to support.  It is starting to get old.  If you wrote a PHP app 20 years ago it would (with minimal tweaking) work fine now.  LAMP stack is still widely used.  Can we say that for Classic ASP aps? Not really, though some decent sites are still powered by it.  What about .net 1 apps?  1.1, 2.0?  MVC 1?  .ASMX web services? Now core?  What happens when Microsoft jukes in a new direction?  Should we constantly be upgrading our apps to feed the beast?
I really like MVC and Sqlite.  For me it is a sweet spot for development.  But I think I'm going to become a real programmer and start branching out to Ubuntu running Node.js.  I bet I can build and app and not touch it for 10 years and it will run fine on the latest version of Node and Ubuntu just fine (though would be ugly as HTML / JS / CSS evolves, but it would still work!).  

Microsoft, you are losing me.

Tuesday, March 28, 2017


For those of us still stuck supporting and enhancing web forms apps, sometimes it is useful to use an xmldatasource to as fake data until the underlying structure can be worked out.  Pasting a sample of an xmldatasource here to remind me of it's format in the future.  This is what you need for combo boxes

<asp:XmlDataSource ID="MyDataSet" runat="server" XPath="/items/item">
        <item desc="field_one" val="some value" />
        <item desc="field_two" val="escape invalid chars" />
        <item desc="field_three" val="vals can by any type just put them line like a string" />
        <item desc="field_four" val="And so on, and so on, and so on" />

To databind xmlsources to grids, you want the data to be laid out more like this

<asp:XmlDataSource ID="MyDataSet" runat="server" XPath="/items/item">
        <item field_one="some value" field_two="escape invalid chars" field_three="vals can by any type just put them lin like a string" field_four="And so on, and so on, and so on" />
        <item field_one="some other value" field_two="escape invalid chars" field_three="vals can by any type just put them lin like a string" field_four="And so on, and so on, and so on" />