Archive for the 'General' Category

Fixing My PayPal "Add To Cart" Button

Tuesday, August 25th, 2009

Intro. I previously blogged about how to create a PayPal "Add To Cart" button at runtime. We use this button on our Buy Now pages. To see an example, click on the following link, and then click any of the Buy Now links:

http://www.edxelectronics.com/PartSearch/PartSearch.aspx?SearchPart=AD5

On this page you'll see the "Add To Cart" button which is created at runtime.

The Problem. This week our users started reporting the following error from paypal.com after they clicked our "Add To Cart" button:

"Sorry — your last action could not be completed"

Yikes! Nobody can buy our products online.

A bunch of googling revealed that PayPal did an upgrade and changed some urls that we were using. And they didn't even tell us!

The Solution. We changed our runtime generated url's from:

    https://www.paypal.com/cart/add=1 . . .

to:

    https://www.paypal.com/cgi-bin/webscr?cmd=_cart&add=1 . . .

and everything went back to normal.

Prevent Backspace From Going to Previous Page

Monday, June 30th, 2008

Intro.  We have one website that is accessible only by subscribers who have a username and password.  The subscriber is presented with lots of data and has the opportunity to add and modify text.

The Problem.  If the subscriber hits the backspace key while the focus is not in an editable field, the website goes back to the previous page.  This causes the subscriber to lose any data that has been entered but not yet saved.  Since there is no reason to return to the previous page, I needed to stop the backspace from going back a page.

The Solution.  I added the following javascript to the < head> section of my webpage (note that I added a space after every "<" so that this editor wouldn't interpret my html):

< script type="text/javascript">
//code to catch the backspace and stops the back default action
if (typeof window.event == 'undefined'){
  document.onkeypress = function(e)
  {
    var test_var=e.target.nodeName.toUpperCase();
    if (e.target.type) var test_type=e.target.type.toUpperCase();
    if ((test_var == 'INPUT' && test_type == 'TEXT') ||(test_var == 'INPUT' && test_type == 'PASSWORD')|| test_var == 'TEXTAREA')
    {
      if ((e.keyCode == 8 ) && (e.target.readOnly == true))
      {
        e.preventDefault();
      }
      else
      {
        return e.keyCode;
      }
    }
    else if (e.keyCode == 8 )
    {
      e.preventDefault();
    }
  }
}
else
{
  document.onkeydown = function()
  {
    var test_var=event.srcElement.tagName.toUpperCase();
    if (event.srcElement.type) var test_type=event.srcElement.type.toUpperCase();
    if ((test_var == 'INPUT' && test_type == 'TEXT') ||(test_var == 'INPUT' && test_type == 'PASSWORD') || test_var == 'TEXTAREA')
    {
      if ((event.keyCode == 8 ) && (event.srcElement.readOnly == true))
      {
        event.returnValue=false;
      }
      else
      {
        return event.keyCode;
      }
    }
    else if (event.keyCode == 8 )
    {
      event.returnValue=false;
    }
  }
}
< /script>

Access DotNetNuke Passwords From Second App

Wednesday, April 2nd, 2008

Intro.  We have one website based on DotNetNuke (FirstSite) with some functions that are available only to the paid subscribers. We have another website (SecondSite) being written in vb.net that needs to be password protected.

The Problem.  The usernames and passwords are stored in the DotNetNuke table aspnet_Membership in an encrypted format (this is optional, but we want encrypted for security).  How can SecondSite access the usernames and passwords of FirstSite in a clear text format for its login page?

The Solution.  The password encrypt/decrypt is handled by the asp.net framework, so I tapped into that.  I added my data source info to my SecondSite's web.config within the < connectionStrings> tag.  I just copied this from FirstSite's web.config (note that I added a space after every "<" so that this editor wouldn't interpret my html):

< add name="SiteSqlServer"
    connectionString=" (your connection string) "
    providerName="System.Data.SqlClient"/>

Then I added these lines within the < system.web> tag.  Again, I just copied these from FirstSite's web.config:

< machineKey (your machine key line) />
< membership defaultProvider="AspNetSqlMembershipProvider"  
    userIsOnlineTimeWindow="15">
   < providers>
      < clear/>
      < add name="AspNetSqlMembershipProvider"
         type="System.Web.Security.SqlMembershipProvider"
         connectionStringName="SiteSqlServer"
         enablePasswordRetrieval="true"
         enablePasswordReset="true"
         requiresQuestionAndAnswer="false"
         minRequiredPasswordLength="7"
         minRequiredNonalphanumericCharacters="0"
         requiresUniqueEmail="false"
         passwordFormat="Encrypted"
         applicationName="DotNetNuke"
         description="Stores and retrieves membership data
         from the local Microsoft SQL Server database"/>
   < /providers>
< /membership>
 

Then I added these lines to SecondSite's login.aspx.vb:

Dim aspnetUser As System.Web.Security.MembershipUser = _
    System.Web.Security.Membership.GetUser(txtUsername.Text.Trim)
If Not aspnetUser Is Nothing Then
    Password = aspnetUser.GetPassword()
End If
If Password <> txtPassword.Text.Trim Then DoInvalidLogin()

Works like a champ!

 

Convert aspx to html

Thursday, November 29th, 2007

Intro.  I wanted to set up a simple (no vb code needed), feeder website with links to our main site.  The webmaster said to give him html pages so he could easily put it on a linux server.  I've been developing in Visual Studio using master pages, so I decided to develop in aspx and then convert to html.

The Solution.  Here are the steps I used:

  • Develop in Visual Studio using a master page.  Don't use any aspx controls – use Html controls instead.
  • Build and run the project in debug mode.
  • Navigate to each page, rt-click, and View Source.
  • Save the source to pagename.html.
  • In all of the resultant html pages replace all .aspx with .html.
  • Ftp the html pages, the images, and the style sheet to the host.

Here is my resulting website:

http://www.leadfreesupplier.com/

 

Online Store

Thursday, May 10th, 2007

Visit our online store at:

http://www.edxtrade.com/

 

Welcome

Friday, March 2nd, 2007

Hello and welcome to The EDX Software Blog.  I am the IT Applications Manager at EDX Electronics, Inc., and I am responsible for our home-grown, in-house software tools, our intranet, and our public website (http://www.edxelectronics.com/).

Our IT department maintains (more…)