Forms within Forms: Upgrading to AspDotNetStorefront 9

Est. Reading Time: 3 minutes

Recently we were in the process of upgrading a site to AspDotNetStorefront 9 and with the upgrade comes multiple changes to how things are coded. One important change is that the entire page is now a form. This form controls all things within it including add to cart or add to wish list. This caused two main problems that I dealt with while trying to integrate the old code into the new.

  • The first one was trying to integrate the old search with the new search. I took what I could from the old code and copied it into the new (shown below). We figured out that the type of image didn’t work so we made it a button and styled as needed to match.
    OLD:   <input name="submit" src="/skins/Skin_1/images/go.jpg" type="image" />
    NEW:   <input id="searchBox_button" name="submit" type="button" value="Go" />

    A few hours later I realized that the add to cart and add to wish list buttons didn’t work anymore and I was getting an error ‘theForm.submit is not a function’. After some quick googling I ran across a page where I immediately realized what was causing this. The page basically states that there was a button somewhere improperly named submit. So I went back to the search form and sure enough I had copied this over from the original code. All I had to do was change the name to something else and voila! It works :)

    FINAL:   <input id="searchBox_button" name="go" type="button" value="Go" />
  • The second issue was integrating a newsletter sign-up form within the main form. The form was in the left column and fell within the flow of the page. When I say this I mean it was positioned relative to other items so it could not be absolute positioned into the left column. This meant that the code had to reside inside the new form. The problem is you can’t have a form within another form.I feel like this was one of those problems that called for thinking outside of the box. Normally you wouldn’t develop something that had this problem but since we are actually customizing something that’s already built (AspDotNetStorefront) and integrating our code into it we needed to find a work around. On my way home my mind seems to subconsciously still be working and trying to solve problems from that day. So as I was driving home that day all of a sudden iFrame! I knew we had used this for different reasons on another site so the next day I tried and it worked like a charm :) This is a solution that could come in handy for multiple things down the road.

One Comment

  1. Posted August 12, 2010 at 2:46 pm | Permalink

    iFrame is a great work-around to the particular problem you’ve described. We’ve used this as a way to get around some of these “sticky” problems in past on ASPDNSF sites.

    Congrats on figuring it out and publishing it so others might learn from your “aha!” moment in the car.