Saturday, November 10, 2012

Visual Studio 2008 Team Foundation Server 2010

After un-installing VS2008 because I never used it and it seemed to have so many issues, I had to re-install it because I had some work that needed to done that used the Business Intelligence part of it. The problem I had was hooking up VS2008 to the Team Foundation Server which was deployed in 2010. I have no idea how it TFS is setup but that was the current configuration.
Of course, my TFS setup flawlessly in VS2010, however in VS2008 initially there was not even a source control option. So here were the steps to get it working:
1. Install VS2008 Team Explorer
2. Install VS2008 Service Pack 1. NOTE: This took a loooong time to install. I even received an error saying it failed to install. Dummy me installed it again...the second time it showed the same problem. I opened up the error log and saw that MOST of it installed but the final component did not. I think there was regarding SQL Server compact or something. SO I made the command decision to ignore this error for the time being until it comes bite me at a later date...
3. I returned back to VS2008 still no go with TFS. I would type in the URL to the TFS server but it could not connect. So I installed VS2008 SP1 forward patch. Still no go....
4. Setup the TFS url like this: https://tfsXX.servername.net/tfs/projectname/ with the final forward slash. It will appear to work, it is NOT - no project show in the Team Explorer....
5. Close VS2008.
6. Open up regedit, edit this key: HKEY_CURRENT_USER/Software/Microsoft/VisualStudio/9.0/TeamFoundation/Servers, remove that final slash.
The regedit tip was provided to me by this post: http://coderjournal.com/2010/02/connecting-visual-studio-2008-to-team-foundation-server-2010/comment-page-1/#comment-69411
7. Now reopen VS2008. Should work now.
Good luck! Although this is probably such old technology that no one will EVER need this post :)

Tuesday, October 16, 2012

Jquery Firefox won't submit form

I was attempting submit a cart checkout page to a hosted order form. I was submitting the form via a jquery call after modifying the form by removing some un-necessary elements and modifying the form action. This worked fine in IE/Chrome but not FF. In FF the form was not submitted. It was apparently due to the removing of the extra elements. I found this post that helped me out:

http://stackoverflow.com/questions/6347433/form-will-not-submit-if-remove-is-used

I was using ASP.NET button as using the submit behavior. I removed the asp.net button and replace it with a plain old html input button and it worked great!

Here is some sample code:

Input Button:

<input type="button" name="btnPayment" value="Checkout" onclick="update();" id="btnPayment">


Javascript:

function update() {



Hope that helps!!!

Tuesday, October 9, 2012

TheThe Image Slider Plugin: Stops working after two images

Ok. I worked on an issue with the TheThe Image Slider which is a plugin for a WordPress site. It is a basic image slider that has several options of showing numerous images. The problem was after a couple of images the slider seemed to stop working. Of course, after searching for a solution, I found the question asked many times with no solution. So I investigated further and hours later found the problem was very simple.

I changed the Transition Time setting from 9000 (ms) to 900 (ms). So maybe the image slider was not stuck but rather waiting 9000 ms? Seems like I waited longer that 9 seconds to confirm it was not moving on. Anyway, I don't know if this was the default setting. I was given the problem to solve so I don't know the initial state of the plugin just that changing it fixed it...

Hope that helps someone!

Tuesday, August 21, 2012

CSS: Absolute Positioning

I was using the JCarousel package to create a 'Related Items' carousel to style the WordPress plugin for 'Related Items'. CSS is a tricky area for me especially things like positioning.

On this particular piece of functionality that I was building, when the user hovered a 'Related Item', an overlay needed to pop-up exactly over it with some additional information.

Basically, a
<ul> tag is created with several <li>, each </li> <li> contains two <div> tags. One is the 'active' div and the other is the 'inactive' div. When the 'inactive' div is hovered you want the 'active' div to show.

For the most part it worked fine, however, I noticed that the first 4 related items worked fine, however, the last would hover up and over to the left rather than right over the image being hovered. So confusing. Anyway, it goes back to understanding absolute positioning.

I had the 'active' class defined like this:

.active {
width:160px;
height:160px;
display: none;
position:absolute;
top:0;
left:-1;
z-index:2;
}

This should pop this div up from its original placement to cover the 'inactive' div.

My problem was solved by explicitly making the parent of this (which in my case was  a <li> classed as 'jcarousel-item') marked as position:relative like so:

.jcarousel-skin-tango .jcarousel-item {
    width: 165px;
    height: 165px;  
    position:relative;  
}

Apparently child items that are absolutely position need the parent to be relative. By default it is static, that is why I was getting the odd last item positioned funny.

This post helped me to better understand things.




Monday, August 20, 2012

HttpWebRequest Time Out HTTPS Call

I recently had some HttpWebRequest calls begin to timeout without any error code returned. Just a timeout. I had not changed my code so I suspected that the site I was calling had changed something.

I found that I could call other HTTPS sites just fine, but this one in particular just timed out. I also tried to bypass all the certificate errors using the code:

ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) => true;

That did not work. I had the break-through moment when I found that if I change the call from HTTPS to HTTP, it worked. Although that was not going to be a fix!

After much searching, I found this post, I submitted the fix to the company and it resolved the problem.

The company had migrated the webserver which was an Apache Server. This small configuration item made some mismatch with the SSL certificate which blocked the HttpWebRequest calls I was making to the HTTPS urls.

Basically, Apache httpd.conf needed to be modified. Here is info from the post:

It had the server name like this: ServerName www.secure.mydomain.com

The certificate was registered to secure.mydomain.com, and the URL I was calling was also https://secure.mydomain.com/xxxx.html.

So simply changing the conf file to the following and restarting Apache did the trick:

ServerName secure.mydomain.com

The following would have also worked, most likely:
ServerName www.secure.mydomain.com
ServerAlias secure.mydomain.com

Hope this saves someone a major headache!

Thursday, August 16, 2012

PHP Location Redirect Error IE

This will be short. You try using the PHP location command to redirect or refresh your page. It works in Firefox but you notice that IE cuts you off with "Page cannot be displayed" error.

Look at your code very carefully:

I had this:
header("location:".$_SERVER["PHP_SELF"]);
exit();

Notice the lowercase "l" and the lack of a space after the colon, this was the problem, this fixed it:

header("Location: ".$_SERVER["PHP_SELF"]);
exit();

Apparently, IE can be picky about this...

Also, make sure you include the exit, it is important...

Tuesday, August 7, 2012

Picup App load image locally rather than using Imgur

A few months back I blogged about using the Picup app to grap iPhone/iPod/iPad pictures from their "i"-device to your website.

The part that has been bugging me was doing a remote upload to Imgur rather than a local upload to my server. I assume Imgur owns any image you upload to them which was a concern of mine.

So I spent some time yesterday trying to figure out my missing piece. I was relieved when I figured out that it was not my lack of brain power :) but rather the technology that I was using. I don't generally use classic ASP. I prefer ASP.NET/C# or PHP any day! With Classic ASP, you cannot easily upload files to your server by accessing the response.form. Instead, you have to download one of several 3rd party components to get the files, which then you have to register the dll blah blah blah.

However, on my server I happened to also have access to PHP. Out of frustration, I thought I will just try all my code on PHP to see if the upload will work. And it did...easily.

So to re-iterate the steps:

STEP 1. Create initial page with an input button, here is a short sample:
<html>
<header></header>
<body class="iphone" onLoad="loadMobile();" >
<form method="post" name="form1">

<input type="file" name="attach1" id="attach1"/>

</body></form></html>
STEP 2. Add script calls to that page.
<script type="text/javascript" src="js/picup.js"></script>
<script type="text/javascript" src="js/prototype.js"></script>
STEP 3. Add javascript function that sets up picup app settings. This function is loaded on the body "onLoad" see step 1. You could probably use jQuery to load this after document ready...
<SCRIPT TYPE="text/javascript">
function loadMobile(){

Picup.checkHash();
var url = escape('http://yourwebsite.com/uploadPhoto.asp');
var posturl = escape('http://yourwebsite.com/get-posted.php');

currentParams = {
'callbackURL': url, //the page called after upload.
'referrername'   : escape('mywebsitename'),
'referrerfavicon'  : escape('http://yourwebsite.com/images/favicon.ico'),
'purpose'               : escape('Select...message to user..'),
'debug'   : 'false',
'returnThumbnailDataURL': 'false',
'thumbnailSize'         : '80',
'postURL': posturl,    //the page that will upload the photo
'returnServerResponse':'true' //returns output of posturl
};

Picup.convertFileInput($('attach1'), currentParams);
}
</script>
STEP 4. Setup the "postURL" page, for me it is a simple PHP file. It outputs the name of the file as the response body so that my callback page can get the file name and update records accordingly.
<?php
if (isset($_FILES)){
 foreach ($_FILES as $key => $file){
  move_uploaded_file($file['tmp_name'], 'photos/'.$file['name']);
  echo $file['name'];
 }
}
?>
STEP 5. Setup the javascript on the callback page to grab the file name...and anything else that it needs.
<SCRIPT TYPE="text/javascript">
var fileName = unescape(getHashUrlVars()['serverResponse']);
var success = getHashUrlVars()['status'];

//parse hashed values from url
function getHashUrlVars(){
 var vars = [], hash;
 var hashes = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&');
 for(var i = 0; i < hashes.length; i++)
 {
 hash = hashes[i].split('=');
 vars.push(hash[0]);
 vars[hash[0]] = hash[1];
 }
 return vars;
}

....process as needed

I hope this helps.