Wednesday, May 28, 2008

IIS 5.1 Server Application Unavailable Error

I get this error sometimes when I change the default application in IIS.
When trying to browse my default.aspx page I get the big red font error "Server Application Unavailable".

I fix this issue by executing the following commands:
1) Give modify access to the "IIS_WPG"and "Internet Guest Account" users to your web directory. Try see if that works, if not continue with step2.


Photobucket

2) aspnet_regiis -i
3) iisreset

Microsoft Instructions:
To fix IIS mappings for ASP.NET, run the aspnet_regiis.exe utility:
1. Click Start, and then click Run.
2. In the Open text box, type cmd, and then press ENTER.
3. At the command prompt, type the following, and then press ENTER:
"%windir%\Microsoft.NET\Framework\version\aspnet_regiis.exe" -i
In this path, version represents the version number of the .NET Framework that you installed on your server. You must replace this placeholder with the actual version number when you type the command.

Then,

1. Click Start, and then click Run.
2. In the Open text box, type iisreset.

Done! Go check out your site it should be up and running.

Ruby: Display datetime - time in words - timeago helper function.

I found this function on the web and putted right into my helper class to display DateTime or Time into words. Displaying time in words is now more used on the web. Popular pages such as YouTube and Yahoo videos use this approach.

Copy the code and plugged into your helper class.




def timeago(time, options = {})
start_date = options.delete(:start_date) || Time.new
date_format = options.delete(:date_format) || :default
delta_minutes = (start_date.to_i - time.to_i).floor / 60
if delta_minutes.abs <= (8724*60)
distance = distance_of_time_in_words(delta_minutes)
if delta_minutes < 0
return "#{distance} from now"
else
return "#{distance} ago"
end
else
return "on #{DateTime.now.to_formatted_s(date_format)}"
end
end
def distance_of_time_in_words(minutes)
case
when minutes < 1
"less than a minute"
when minutes < 50
pluralize(minutes, "minute")
when minutes < 90
"about one hour"
when minutes < 1080
"#{(minutes / 60).round} hours"
when minutes < 1440
"one day"
when minutes < 2880
"about one day"
else
"#{(minutes / 1440).round} days"
end
end

Tuesday, May 27, 2008

Ruby: Format seconds into minutes to_minutes function

I created this function to turn seconds into minutes.
Example: 500 seconds should be displayed as 8:00 minutes.




def to_minutes(seconds)

m = (seconds/60).floor
s = (seconds - (m * 60)).round

# add leading zero to one-digit minute
if m < 10
m = "0#{m}"
end
# add leading zero to one-digit second
if s < 10
s = "0#{s}"
end
# return formatted time
return "#{m}:#{s}"
end


Tuesday, March 25, 2008

IE caches IFrame pages. Page load does not fire in IFrame page.

I had this issue on a project that I was working on. I created an IFrame to load a page in a modal window. On the close of the modal window I will close the frame, and then when the user clicks on a button to open the window I will recreate the frame with the same url to load the page. This worked fine with FireFox. On every load of the modal window I the Page_Load event will fire, however, with IE this was not the case. I solve the problem by creating a unique request every time setting a parameter with a random number in the source of the IFrame.


Iframe.src="MyPage.aspx?unique="+ Math.random();

Thursday, March 20, 2008

Aivea eShop Shopping Cart is NOT Enterprise Ready (Review)

After looking for e-commerce solution for my store shopping cart I made the decision to go with Aivea eShop product. Their website ‘professional’ looking was what convinced me to buy it. However, when I downloaded the product with the source code I was shock. I have work in “Enterprise wide” applications and the eShop source code is not enterprise ready as they claim in their website.

These are my disappointment factors:

  • Source code uses Hungarian notation.

  • In store front website source code they persists almost every value in the session in the session.

  • They don’t use strong typed entities. I only noticed 3 or 4 object to used to get data

  • Heavy used of data sets instead of objects

  • Not a flexible architecture. Business rules and data access is all in the App_Code folder. If you have more than one interface that needs to access the shopping cart to process order or retrieve order orders you can’t accomplish it without serious re-factoring and extracting the source code to reusable components.


I am sure I can find other reasons but I will stop here. This was the reason I decided not to use it in my application. Towards the end of the project I was so happy that I did not use this out of the shelf solution that encouraged me to write this article.



I am not writing this post to drive off their business, but to express my believe and make them be aware of what a user is thinking about their product. By the way the version that I used was 2.5+.



You can find more reviews here at
http://www.411asp.net/func/review?id=6449910&rid=&proc=anony

Tuesday, March 18, 2008

DetailsView Edit Mode never changes after Update command. DetailsView Edit button requires to clicks to change to edit mode.

I was stocked for sometime using the asp.net 2.0 DetailsView control to Edit/Update data. I wanted to do my custom implementation for the Update command instead of using the DataBinding Object sources but I found my self in trouble with several road blocks.

Problem 1:
When clicking on the Edit button the DetailsView will not change the mode until the second click. The edit button required two clicks to change the mode to Edit instead of ReadOnly.
I solved this problem by changing the mode in the ModeChanging event handler and then rebinding the DetailsView control.


ModeChanging Event Handler:

protected void dvOrder_ModeChanging(object sender, DetailsViewModeEventArgs e)
{
dvOrders.ChangeMode(e.NewMode);

if (e.NewMode != DetailsViewMode.Insert)
{
RefreshOrderDetails();
}
}




Problem 2:
When clicking the update button I handle the updating of the order in the ItemUpdating event but the ItemUpdated never fires and the DetailsView never change the mode to ReadOnly after the data was updated. DetailsView control always stayed on the Edit Mode.


I solve this problem by canceling the ItemUpdating event, changing the mode, and rebinding the details view data source.


ItemUpdating Event Handler:

protected void dvOrder_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
{

UpdateOrder();

e.Cancel = true;

dvOrders.ChangeMode(DetailsViewMode.ReadOnly);

RefreshOrderDetails();
}



This was the only way I got things to worked for me. The ItemUpdated event never fired but I got the DetailsView to works how I wanted. I wish there was an easier way to do this or at least more documentation on Microsoft’s website.

Tuesday, March 11, 2008

IE Autocomplete Dropdown wrong location in Modal/Dialog window ASP.NET 2.0

I recently discover that if the AutoCompleteType attribute is not specify explicitly in the input control IE will display the autocomplete options dropdown in offset location in modal/dialog windows.

This is not the case if you are using Yahoo's tool bar or Google's auto fill feature in its tool bar, but IE is more stupid.

I fixed this issue my explicitly settings the AutoCompleteType attribute in the Textbox control.

Example textbox for first name field.


<asp:TextBox ID="txtFirstName" CssClass="input" runat="server" AutoCompleteType="firstname"></asp:TextBox>




By setting the AutoCompleteType attribute the problem was corrected.

Tuesday, February 26, 2008

JavaScript Validate Email using RegEx

Use the code below with an asp.net custom validator to check if an email is valid.
The code below check for a value if no value is provided then is not a valid email.

The pattern below will work with gmail's email address with "+" such as johnsmith+test@gmail.com



function ValidateEmail(sender, args)
{
if(args.Value.trim().length > 0)
{
var ex = /^([a-zA-Z0-9_.+-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
var re = new RegExp(ex );

if(re.exec(args.Value))
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}

}
else
{
args.IsValid = false;
}
}



Monday, February 18, 2008

Credit Card Expiration Date Validation -Javascript Function




function ValidateExpDate()

{

var ccExpYear = 20 + $F('<%= txtCCExpirationYear.ClientID%>');

var ccExpMonth = $F('<%= txtCCExpirationMonth.ClientID%>');



var expDate=new Date();

expDate.setFullYear(ccExpYear, ccExpMonth, 1);



var today = new Date();



if (expDate<today)

{

// Credit Card is expire

return false;

}

else

{

// Credit is valid

return true;

}

}



Wednesday, February 13, 2008

Compilation Error CS0433

I fixed this error by changing the Page Property CodeFile to CodeBehind on the mater page and the content pages.

Use CodeBehind when working on Web Application projects in ASP.NET 2.0

Tuesday, January 22, 2008

VS.NET 2005 Close Tab on Double-Click

Anyone out there knows how to enable the functionality to close a tab document in vs.net 2005 on the double-click action just like firefox extensions?

I hate to use the middle button and will like to use the double click.

Thanks

Saturday, December 08, 2007

17 Search Engine Reputation Management Optimization Tips

I recently got this e-mail from a friend of mine. The tips listed below are very true for increasing your website to be in the top of search results when searching for keywords related to your site. I followed several of these tips when I worked for a software automation company. In one to two weeks I started noticing that the bots were checking for often the company's website and the keywords searched in Google were listing the company's website to the top.

-
-----------------------------------------------------------------------------------------------------
17 Search Engine Reputation Management Optimization Tips
by Rob Garner, Wednesday, November 7, 2007

AS IT IS BECOMING MORE commonly accepted that Google, Yahoo and MSN are reputation management engines just as much as they are search engines, more folks are seeking information on how to increase positive visibility for a personal or corporate name. Here is a quick list of 17 different ways to optimize for positive visibility for your personal or brand name:

1) Add your profile to LinkedIn, and build a real page with real connections.

2) Create a site with your exact keyword or name domain, and add useful and unique content.

3) Use paid search to enhance your site visibility. The engines give you two basic opportunities for placement -- paid and natural. Consider using them both if it will help achieve your end goals. This does not mean that a defensive stance is required in the copy, but it can help increase visibility, if needed.

4) Take inventory of all of your existing sites. Determine if they are properly optimized for your target brand or name keyword set. If not, start filling in the gaps with optimized pages, and optimized title and meta elements.

5) Use various optimized digital assets -- particularly video. Video and image results can attract eyeballs away from everything else on the page. Make it useful, funny, or otherwise unique and entertaining.

6) Write useful content and establish yourself or your company as an expert, either for your own site, or for other blogs. Good content naturally finds itself at the top of the search results, and its creators are often rewarded with link citations, writer profile pages ! and high rankings as a result.

7) Link strategically. I don't want to sell this one short, as it is one of the most important elements, but leverage your on-theme sites and link to other relevant sites to help push them up higher in the results.

8) Leverage your good domain for search benefits by creating a subdomain for your target term. Add valuable and useful content. Corporate sites should seriously consider architecting around subdomains, as they are treated as separate domains by the engines.

9) Create a profile on various social media sites like MySpace and Flickr. Also note that content entered into Flickr is entered into a Creative Commons license.

10) Start a blog on WordPress. Plan on investing time and making it a real blog.

11) Start a WordPress blog on your own domain.

12) Avoid putting out any material that you wouldn't want in your primary namespace. An ounce of prevention is worth a pound of cure.

13) Create a Naymz profile.

14) Send out a press release, or two. Or twenty (over time, of course).

15) Have someone interview you about your passion. Publish the interview on your site.

16) Create a search roll at Rollyo of search engines and topics you really like.

17) Be very, very patient.


Rob Garner is strategy director for interactive marketing and search agency iCrossing and writes for Great Finds, the iCrossing blog. He is president-elect of the Dallas/Fort Worth Search Engine Marketing Association, and also serves on the board of the Dallas/Fort Worth Interactive Marketing Association.

Friday, December 07, 2007

Enterprise Library Logging Timestamp format

Just for awareness the Microsoft Enterprise Library Logging Application Block for flat file trace lister allows to specified the time stamp format in the template formatter as
{timestamp(local)} for local time zone time stamp or optionally you can specified your DateTime format such as MM/dd/yyyy HH:mm:ss.

See .NET Standard DateTime String Formats at http://msdn2.microsoft.com/en-us/library/az4se3k1(vs.71).aspx

Thursday, December 06, 2007

i.c.stars is recruiting for Cycle 16 January 2008 – Technology Jobs

i.cstars is currently taking applications for cycle 16 of technology, business and leadership training. You can apply online at www.howcanicstars.org.

i.cstars offers free training for high school or GED graduates that want to acquire technology, business, and leadership skills. At the end for the intensive training, graduates will have a change to be recruit by companies seeking i.cstars graduates to fill positions in Software Development, Business Analyst, Testing, Networking, Computer Technicians, Computer Design, Game Development, and other technology related jobs.

Information sessions are held every 2nd Tuesday at 6p.m at the Chicago location. Find more information about the information sessions at i.cstars.org.

I am an i.cstars Alumni from Cycle 7 and I join i.cstars right after graduating from High School in Chicago Illinois. Five months after completing my training I was working as a Software Developer for a Software company in Chicago at 19 years old with a great salary.


If you think this interest you, don’t wait any more. Call i.cstars now. Oh by the way I forgot to mention. During the time you are learning at i.cstars you get a monthly check!

Friday, November 30, 2007

WebLoad posting form data as files for Ajax applications

I have an application that is doing and Ajax callback XHTMLrequest to an .ashx handler. Web launch WebLoad to record an agenda to capture the Ajax posts WebLoad was recording the agenda using the CopyFile function similar to:

CopyFile("wl3941127422.dat","wl3941127422.dat")

After digging I found out that there was a setting in the recording options "Record unknown post types as file". I un-check this settings and tried again to record the agenda an changed the way the form was posting recording the actual form data in the JavaScript Agenda.


Change this setting by going to:

WebLoad IDE --> Tools --> Recording Options --> Post Data --> and un-check the "Record unknown Post Types as File"

Thursday, November 29, 2007

Google's Grand Central - The New Way To Use Your Phone Number

I recently got an invitation to use Google's GrandCentral online service that allows me to pick a phone number and have it forward to any telephone I want. It simply can be your only phone number for life. At any time you can change the forwarding number.

I used to have AT&T VOIP service and they have an online service where I can check my incoming and outgoing calls, check voice mail and other similar functions.

GrandCentral can send all your voice mails to your e-mail so that you don't miss a voice mail message.

What I think is best is the availability to block callers, reject calls, send calls to your voice mail.

This is how it works:

Caller calls your GrandCentral number  GrandCentral calls your phones  You get a call and you take an action

Here is a screen shot of the control panel:
Google Gran Central Control Panel


So far the service now is for free for one phone number. However, when it comes out of beta I am not sure how much they will charge for the service.

Tuesday, November 27, 2007

How to use the SubSonic Collection Find() method with Predicate

Here is a code example to find a particular item within a collection of entities.




Instead of creating a loop to go over the collection to find your entity, you can take advantage of the Predicates.

Model.Person foundPerson =(Model.Person) personCollection.Find(delegate(Model.Person e) { return e.FirstName == "John"; });




I hope this is helpful. I did not find anything in the SubSonic forums regarding the Find method. This worked for me instead of creating a loop to go over all items in the collection.

Monday, November 26, 2007

SubSonic Updated Templates to Delete Entities With Children

In a recent project that I worked on I had a need to delete a top entity that had multiple children. With the generated code out of the box from SubSonic I found it difficult to delete the parent entity and all the children that depend on the parent entity since I had to specifically invoke the child entity for a delete operation. So I decided to mess with the templates. In particular with the 'Controller' (CS_ODSController.aspx).

I decided to create a method named "DeleteWithChildren()" that will take the primary key id of the parent entity to follow the same controller pattern already in place similar methods.


DeleteWithChildren() will go load the parent entity using the primary key and then invoke the corresponding controller class for each of each children.

For example,



public void DeleteWithChildren(object keyID)
{

// Load the entity
MyCompany.Model.Employee entity = new MyCompany.Model.Employee(keyID);

foreach(MyCompany.Model.SiteEmployee child in entity.SiteEmployeeRecords)
{


MyCompany.Controller.SiteEmployeeCtrl.Instance.DeleteWithChildren(child.SiteEmployeeId);

}


}




This allowed me to simple invoke the parent entity controller such as Controller.ParentEntity.DeleteWithChildren(5000); and have the controller delete everything the hangs off the ParentEntity object by calling the DeleteWithChildren() method for each child. This allows to delete hierarchical entities.

You can download the template file from my online box here.

My template was code to first check that a transaction was started since you might not want to attempt to delete everything from that entity without a transaction.

Dell Inspiron 1720 Windows XP Pro Working Audio Driver SIGMATEL STAC 92XX

After wiping out Windows Vista and installing Windows XP Pro SP2 in my Dell Inspiron 1720 I found my self in trouble. I could not find any where in Dell's web site or forums the driver for the sound device for my laptop.

After several hours of search and trying different drivers I found a driver only available in Dell's German Language for the SigmaTel sound card R153908.exe.

You can download it from Dell's website here or you can get it from my online box here.
Just donwload run the file it will extract all the files to a directory default "c:\dell\drivers" and the setup will be launched.

Wednesday, November 21, 2007

Free Screen Capture For Windows - Cropper

Cropper is an open source screen capture tool written in C# .NET that allows users to mark a region in their desktop and take a screen capture and save it to any image type format.

Its simple, light weight and its free.

Cropper was support for plug-ins (extensions, add-ons what ever you want to call it). You can create your own extension in .NET to enhance the functionality of cropper.


I used it for my development for to take a snapshot of an error for example and then automatically uploading the capture image to the issue management application such as “Mantis”.

Compare to SnagIt, cropper does not have all the features in SnagIt out of the box but there are several extensions for cropper our there that can provide a similar functionality. You’ll find the plug-ins download sites here.