Friday, July 27, 2012

Putting Javascript in an XSLT Stylesheet

There was some code from a previous developer that I had to edit. He had used XML and an XSLT stylesheet to display a form to the user. I needed to add some javascript to hide and show a div when an existing button was clicked. There was an <xsl:template tag and I had to put the script tags and the javascript in there.


<xsl:template match="/*">
    <script language="JavaScript" xmlns:msxsl="urn:schemas-microsoft-com:xslt" >

      function toggle(ID)
      {
      var element = document.getElementById(ID);

      if(element.style.display == "block")
        {
          element.style.display = "none";
        }
      else
        {
          element.style.display = "block";
        }
      }
    </script>

Thursday, July 26, 2012

Redisplay Dynamic Controls Every Time ASP.Net

I had some controls that I was dynamically creating.  When I would click my button to postback I was finding that the code had no idea about those controls, even though I could see them in the page I just posted.  The controls were also still there when the code returned to the web page.

It turns out that you have to recreate the dynamic controls every time.  I avoided this answer, since recreating the control I thought would reinitialize the values and I would lose what the user has chosen on the page.  It turns out the viewstate figured it out and just needed to the control to be created each time for it to have a place for it to save its values.

It looks like Page_Load and Page_Init both work for this purpose.

mm is not MM

Even though when you call a ToString() on a DateTime the day and year format characters are dd and yyyy, respectively, that does not mean that the month part is mm.  mm is already used to format for minute.  I spent a while today trying to figure out why I was getting a number that was beyond the range of 1-12 for the mm portion of my date when using ToString(mmddyyyy).  You have to use MM for your month portion.

Thursday, June 21, 2012

Have You Ever Done Any Debugging?

A while ago I was contacted by a recruiter.  One of the screening questions was, "Have you ever done any debugging?"

Maybe there is some type of software development that I am not familiar with where you don't debug code.  In my definition of software development debugging is mostly the main job.  Not only are you debugging the code you write and the code others have written, but you also have to debug the users process and perceptions.

Even if you count out debugging the user, I can't imagine why someone would list debugging as a requirement for a software developer, since it is implied in the title.

I also find it somewhat ridiculous that one that is sent to find candidates for a programming job hasn't been trained enough to know that programmers debug by definition.  It makes the recruiter look less than competent.  It makes the recruiting company look bad.  It also makes the company that is looking for a programmer look like they don't have it together.  Quite likely the company looking to hire someone is perfectly fine, but the recruiter hasn't been trained properly to be able to find candidates.

What's In a Name

Over the last 15-20 years of my programming career my title has changed all over the place while doing essentially the same job.

In some jobs I have been titled a programmer.  In others an application developer.  Still others I was called a software developer.  One employer called me a software engineer.

The engineer title was a little much for what was going on.  Even the title architect seems a bit much.  Perhaps there are those that get degrees in software architecture or software engineering, but it kind of leave my paradigm of what engineers and architects are.

The name 'Request' does not exist in the current context

I receive this message today in Visual Studio when trying to get at the Request object of a web page and it stumped me for a bit, since it did not represent what the actually problem was.  "The name 'Request' does not exist in the current context"


I had this code in the Page_Load event:
     if (Request("myFlag")=="1") DoSomething();


Since I had seen similar code elsewhere and I was in a Page_Load I was pretty sure I had the Request object available to me.


I tried going at the base page.  I tried using "this".  None of them worked.


As I flipped things this way and that I had something pop up that made me realize I had wrapped the parm of the Request object in parenthesis instead of brackets.  Once I changed that it fixed the problem.
    if (Request["myFlag"]=="1") DoSomething();


The error message was misleading.  While a method named Request was not in the current context, the problem actually was that I was using an object like a method.  I will admit that I probably made this mistake because I bounce back and forth between VB and C#.  Perhaps developers that exclusively do C# and Java would not be tripped up by this.

Tuesday, April 17, 2012

How To Backup a Blogger.com Blog

For a long time I used a utility called Blogger Backup, which had been uploaded to CodePlex.  It never really got all the kinks worked out of it and had not been updated for a long time, but it was good enough.

I was feeling like posts were disappearing from my blog, but I couldn't put my finger on a specific event or post that was disappearing I started to suspect maybe a bug in Blogger Backup, but I had no proof and still have no proof to this day.  I started looking around for other options.  Every time I would search I just kept getting pointed back to Blogger Backup.

Finally I began to wonder if Google hadn't built in a backup utility into blogger or an export or something after all these years.  I did some searching and found that there was something in Basic Settings.  The post must have been old, because there was nothing there dealing with export.  I happened upon the Other category under Settings.  There was the option that they had described in the post which stated it should be under the Basic section of Settings.

Here's what you do.

  1. Log into blogger.
  2. Go to the listing of your blogs.
  3. Click on your blog.
  4. On the left click the Settings item.
  5. It will expand and in there click the Other item.
  6. You will be presented with several things in here.  The one at the top is Blog Tools.
  7. In there you will see Import Blog, Export Blog, and Delete Blog.
  8. Click Export Blog.
  9. You will be prompted to download an XML file.  Click download and then give it a location and a name.
I would like a way to download all of my blogs in one click, but for now you have to do one by one.  They could perhaps give us the option to download all and let us choose a naming pattern for the files it would generate.  The advantage of doing them one by one is that you can uniquely and specifically name each blog's file.

So if you need to backup your blog, which everyone really should be backing up, you can use the old Blogger Backup or you can use the Export Blog feature from with Blogger to export an XML file.