Charlie's Blog


Home Account Search
ASP.NET and Firefox: Link in GridView not Responding (JavaScript Error: theForm is undefined)
Source Link: http://stackoverflow.com/questions/1389625/asp-net-and-firefox-why-doesnt-clicking-on-a-gridview-buttonfield-do-anything

ISSUE: Using a GridView with a LinkButton was not working, but only in FireFox. Worked fine in IE. Turns out during devleopment we were simply making blank .aspx pages with User Controls (minus the HTML, TITLE, and BODY tags). (as in right cilck, Add New Item, Web Form). Typically we add the User Controls to an already made HTML template and do not run into this issue.

SOLUTION: "This is due to a difference in how the browsers handle Javascript in the presence of invalid HTML: specifically, when the form is not surrounded with HTML and BODY tags. Without these tags, Firefox seems to try to initialise the variable theForm before the form actually exists.

Adding the proper HTML and BODY tags around the form (as is required for valid HTML in any case) makes the click handler work in both IE and Firefox."
Website Special Characters - utf-8 - Get Rid of the Gremlins!
1. Add the following to the head section of your web page web site template:

   < meta http-equiv="content-type" content="text/html; charset=utf-8" />

2. Add the following to the web.config in the system.web section:

   < globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US" fileEncoding="UTF-8" />

The key in step #2 is the fileEncoding="UTF-8"
reCAPTCHA - How to Disable Client Side Cookie
recaptcha:RecaptchaControl
   ID="RecaptchaControl1"
   runat="server"
   PublicKey="[your key]"
   PrivateKey="[your key]"
   nocookie="1"
XSLT - Check for Empty Node - When Databse NULL
Testing for SpecSheets_C[.!=''] where SpecSheets_C is the name of the xml node / name of database field.

<xsl:param name="pSpecSheets">
  <xsl:value-of select="SpecSheets_C"/>
</xsl:param>

<xsl:choose>
  <xsl:when test="SpecSheets_C[.!='']">
    <p>Product Spec Sheet: <a href="{$pSpecSheets}" target="_blank">click here</a></p>
  </xsl:when>
</xsl:choose>

helpful link: http://www.dpawson.co.uk/xsl/sect2/N3328.html
Google Map with Multiple Points
<head runat="server">
   <title>Google Maps JavaScript API Example: Map Markers</title>
   <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA4y7TGWlLmwZsWI96T4ikNBSOa-KbVWalemU97-VMUEoLuMlh4RT7SG0ml56sZDsTiTicZ-H1lc2ClQ" type="text/javascript"></script>

   <script type="text/javascript">

   function initialize() {
     if (GBrowserIsCompatible()) {
       var map = new GMap2(document.getElementById("map_canvas"));
       map.setCenter(new GLatLng(37.7057286786, -77.763161873), 6);
       map.setUIToDefault();

       var point = new GLatLng(37.8103130403, -80.1885403566);
       map.addOverlay(new GMarker(point));

       point = new GLatLng(37.7968722222222, -79.7125694444444);
       map.addOverlay(new GMarker(point));

     }
   }
   </script>
</head>
<body onload="initialize()" onunload="GUnload()">
   <div id="map_canvas" style="width: 500px; height: 500px"></div>
</body>
Add Existing Flash (.flv) Video to Website
Example Project Requirements:
1. Video must not start playing automatically on page load
2. Video files must not be stored in the same directory as the .flv and .swf

Solution:
Phase 1
1. Create new Flash Project using Adobe Flash (used to be Macromedia)
2. Import the .flv into the new project
3. Select skin if necessary for interactive features
4. Make any necessary adjustments (e.g. set AutoPlay to false, resize canvas and video)
5. Save and Publish the project (this generates the assoicated .swf and .html)

Phase 2
1. Copy .swf and .flv to appropriate directory (keep these files together in the same directory)
   - note: if you chose a skin, you will need to copy the skin .swf file as well (e.g. SkinUnderPlayStopSeekMuteVol?.swf)
   - note: you do not need to upload the .fla to the webserver; it is just the Flash project file and is of no use on the web.
   - note: the 'base' parameter tells the .swf to look for files relative to its location (this is needed to get the skin to appear)
2. On the desired web page, copy the below HTML code into the body of the web page and adjsut the directory paths as needed:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="610" height="495">
   <param name="movie" value="/video.swf" />
   <param name="base" value="." />
   <!--[if !IE]>-->
     <object type="application/x-shockwave-flash" data="/video.swf" width="610" height="495">
       <param name="base" value="." />
     </object>
   <!--<![endif]-->
</object>
Interprise Suite 2007 with AspDotNetStoreFront

A recent e-commerce / ERP project required us to use of Interprise Suite 2007 with AspDotNetStoreFront.

Initially, we were frustrated with the installation of the software package and the quality of the customer support, which is partially based in the Philippines. The support team seemed to be a relatively small group and never returned my calls at the agreed upon times.  Each service call usually involved speaking with multiple representatives that all had to “get back to me later.”

Once you get the software up and running, it is quite robust and impressive.  However, we ran into issues with the software installation that the documentation did not cover, but should have.

Basically, the issue came down to how we have our in-house development server set up.  Our setup was provided to us by professional server specialists and is based on Microsoft standards for efficiency and security.  The catch is that we use Application Pool Isolation to allow our customers to view their sites remotely.  The Interprise Suite 2007 software required that we change the permission settings to the Windows/temp directory on the server.  This was not described in the setup guide.  This simple fix, did the trick, but caused hours of frustration and communication with customer support.

The software also requires setup in a client/server environment.  Doing so was not specifically outlined in the documentation.  The software uses a couple of web services that need to be hooked into the back-end after installation in order for it to communicate with StoreFront. 

The software essentially replaces the "old way" of accessing StoreFront via a web browser and you now get to maintain all of the StoreFront settings from a new interface.  This single interface gives you control over EVERYTHING including website settings, inventory, billing, shipping, etc, etc.

Unfortunately, even after getting everything set up correctly and adjust to the new user interface, the software tends to crash frequently.  A sales representative at StoreFront (not Interprise Suite) informed me that this was not the first time they have encountered a caller describing similar issues.  This representative told me they have had customers flat out switch to something like Great Plains software due to similar frustrations.

Although this software has good intentions and seems like it should be viable ERP software, I would recommend researching the latest version vs. alternatives until they get the kinks worked out.  The latest version or maybe the next version may be more stable and provide better documentation and support.

HttpCookie and HttpCookieCollection

Good to know: The HttpCookieCollection returns String representations of HttpCookie objects. Meaning, for example, if an HttpCookie is named "myCookie" then "myCookie" is all you get out of the HttpCookieCollection in the form of a key you may use to get the actual HttpCookie object. You can declare and instanciate a HttpCookie object using the key from the HttpCookieCollection. Seems odd that they come out as Strings and not HttpCookies, but that is the deal. 

The example below shows how to check to see if a Cookie exists in the current HttpContext. I am sure the below solution could be abbreviated by just checking for the exsiting key name and not actually creating a HttpCookie object. However, if you need anything more than the name of the HttpCookie, you would need to create an object (e.g. value, expiration date, etc.).

Dim cookieExists As Boolean = False

' Current cookie collection
Dim Cookies As HttpCookieCollection
Cookies = Web.HttpContext.Current.Request.Cookies

' Look for specific cookie
For Each strKey As String In Cookies

    Dim cookie As HttpCookie
    cookie = Cookies.Get(strKey)

    If cookie.Name = "myCookie" Then
        cookieExists = True
    End If

Next

' If the cookie is not found, create a new one
If Not cookieExists Then
    Dim myCookieAs New System.Web.HttpCookie("myCookie")
    Response.Cookies.Add(myCookie)
End If

favicon.ico
In order to get this working cross browser, especially in IE, I had to save a 16 x 16 .gif in .ico format (not just change the extension to .ico from .gif). I am not a Photoshop wiz and I could not find the option avilable to save as .ico (also too lazy to lookup solution online :)). However, I use Gimp from time to time in a pinch, http://www.gimp.org/ (external link), which has the option to save as .ico wtihout any issue (available online for free!). This did the trick, and I saved the favicon.ico to the root of the website.
Extreme Programming and Deadlines

Deadlines are very common in our line of business.  Clients have varying demands and high expectations.  Our team is always managing multiple clients and projects at the same time.  This is a constant challenge for everyone on the team.  I am happy to report that we constantly meet or exceed our clients expectations which of course is very rewarding for us.

I personally enjoy the challenge of providing our clients with quality, working software  as efficiently as possible.  Recently, our team began to adopt a formal methodology for improving the way we interact internally, as well as how we interact with our clients, to help improve the success rate of our projects.  This formalized process, among other things, also increases client involvement throughout the entire project which has reinforced for us that keeping the client in the loop at all times is a critical element of a successful project.

Practical e-commerce solution using BV Commerce

Recently we launched an e-commerce website for my uncle’s business, Southern Distributors, Inc.  www.southerndistributorsinc.com.  Southern Distributors is a general merchandise wholesale distributor and they carry over 5,000 different products. Based in Richmond, VA, they have been providing distribution services for over 60 years.

For this project, we selected BV Commerce by BV Software www.bvsoftware.com.  This is a Richmond, VA based software company.  I personally worked with the founder and primary developer of this software during college.  It was interesting  to work with the software a few years, and versions, later as a professional web developer. 

The user interface of BV Commerce is intuitive and easy to navigate.  The software, including the source code, was a modest $500 bucks (now closer to $1000).  It has all the fundamentals for running an e-commerce website.  If you are accustomed to .NET 2.0+ programming standards, you will find the source code to be organized and useful. If you do not require a super robust software solution, BV Commerce is very practical and economical.

Sixty years after opening their doors, Southern Distributors, Inc. is now advertising and selling products using an e-commerce website!