asp.net onClick not executing

I am filing this in the category of WTF (What Terrible Functionality). 

We have all created forms with many different input controls that post back information we then process in some way.  Our users have come to expect that when they hit enter while filling out the form that it will trigger the submission of the form, and we usually do the processing through the onClick event of the submit button. 

I was creating a very simple form 1 textbox and a button that was to be used for a search page for an Intranet site.  During testing I discovered that sometimes this worked just fine and other times it didn’t work at all.  I could not figure out from users descriptions what they were doing differently.  I started paying special attention to the testers and how they were submitting the search criteria.  One user would type the search string then press tab, highlighting the submit button then press enter.  Another user would type the search criteria then with the mouse click the submit button.  It worked properly for both of these users.  But, one user would enter the search criteria then with the cursor still in the text box would hit enter.  It wouldn’t work.

This is an issue with the way that IE submits form data in the special circumstance of one textbox control on a form and the user pressing Enter while the textbox has focus.  4 Guys from Rolla have an excellent article that explains this behavior Enter and the Button Click Event.  Basically, IE does not submit the buttonID – Value pair for the submit button in this special circumstance.  4 Guys from Rolla offer a workaround of adding a second textbox and hiding it.

I think Microsoft, if they are aware, need to re-program this functionality in IE to always submit the buttonID – Value pair.  Other browsers work this way so its not impossible.

5. February 2009 13:41 by Duane | Comments (1) | Permalink

asp:ListView Insert and Update not working

I have been working on a solution that used the asp:ListView to manipulate data from an access database.

After defining the Layout, Item, EditItem, and Update Templates I was impressed with how much control I had over the display formats and CSS integration that this control allows.  The template I was using is a standard html table.  The display of the data worked perfectly, but when I attempted to edit a record it replaced everything with blank values.  Inserting a new record either gave me an error or inserted a new record with all the fields blank.

I started to troubleshoot by looking at various examples and tutorials on MSDN and the Internet.  I could see no difference between what I had coded and the examples.  I was using an AccessDataSource and all of the examples were using SqlDataSource, so I redefined the data source to be Sql and still the same behavior, display worked fine but editing did not work. 

I am one of those people who prefers to hand code as much as possible to make sure that I am understanding what is happening and how the controls work.  But, I had reached my limits, I just could not figure out what I was doing wrong.  I broke down and used the wizard for the ListView and let it create the templates and data source.  This worked. 

So after looking at the templates I discovered one little difference.  In my Item templates I had defined the <tr> tags to include the runat=”server” directive.  I removed this directive and everything started working like it is supposed to.

Why did this fix it?  Well, as near as I can figure when the items are inserted into the template replacing the itemPlaceholder the runat=”server” directive in the item templates overrode / hid / replaced the methods from the itemPlaceholder.

30. January 2009 09:30 by Duane | Comments (1) | Permalink

Business Leaders Listen Up! Inter, Intra, and Extra nets are not the same!

Contrary to what Content Management System (CMS) sales and marketing forces around the world want you to believe, Internet, Intranet, and Extranet are not the same thing.  Pay attention I am only going to explain this once…  These business tools are not used or delivered in the same way, have different goals, and have different technological requirements.

You still need more of an explanation…  Lets start with some vocabulary.

Internet
The Internet is a global system of interconnected computer networks that interchange data by packet switching using the standardized Internet Protocol Suite (TCP/IP). The Internet carries various information resources and services, such as electronic mail, online chat, file transfer and file sharing, online gaming, and inter-linked hypertext documents.  The Internet is open to the general public. Wikipedia
Intranet
An intranet is a private computer network that uses Internet technologies to securely share any part of an organization's information or operational systems with its employees. Sometimes the term refers only to the organization's internal website, but often it is a more extensive part of the organization's computer infrastructure and private websites are an important component and focal point of internal communication and collaboration. An intranet is not open to the general public.  Wikipedia
Extranet
An extranet is a private network that uses Internet protocols, network connectivity, and possibly the public telecommunication system to securely share part of an organization's information or operations with suppliers, vendors, partners, customers or other businesses. An extranet can be viewed as part of a company's intranet that is extended to users outside the company.  An extranet is not open to the general public. Wikipedia

Let me see if I can further clarify…

There is only one Internet (notice the uppercase “I”. Some people will argue, correctly, that an intranet is just interconnected computers and these internets are not public domain nor are they necessarily connected to each other.  I am not talking about that internet (lowercase “i”))  Anyway, I digress… there is only one Internet.  This is the public computer based advertising and selling arm of your company.  This is where you interact with “John Q. Public”.

Your companies intranet is where you post all the juicy little bits of information you don’t want other companies and “John Q. Public” to know about.  HR policies, internal procedures, inventory controls, cost structures, financial data, and the company newsletter all are perfect candidates for your intranet.

Your companies extranet is where you allow someone from a trusted external company to authenticate themselves and then gain access to selected information about your company.  WalMart is using an extranet to allow suppliers to check the inventory levels for the external companies products at each of its stores.  This is not open to the public.  You have to provide secure methods of connecting and authenticating.  Can you imagine what would happen if Huffy found out Schwinn bicycles login?  Or if one supplier found out the cost of another competing suppliers product? 

So, when that sales person tries to sell you on the fact that their CMS is capable of handling your Internet, Intranet, and Extranet content take a moment and think about that claim.  Can they really control access to your most private business secrets on the same system that holds your publicly accessible Internet content?  What would happen to your company if your competitor or even a supplier got into the wrong area?  Invite your IT staff to the meeting and let them ask the technically specific questions about how the CMS system will work.  Then listen to your IT staff about their concerns before deciding on a CMS provider.

16. January 2009 13:59 by Duane | Comments (0) | Permalink

Back-at-you Google Maps Streetview

So I was driving to work when I notice a car with some strange apparatus mounted to the roof.  I was headed north on I-15 between Farmington and Layton.  So I catch up with this car... 

Unfortunately, the camera on my cell phone didn't pick up the bumper stickers from the glare but they say Google Maps.  The dot about 3 feet above the roof is the 360 degree camera used for Google Maps Streetview.  So keep your eyes open on I-15 on Google maps and you might just catch a glimpse of me. 
7. May 2008 22:54 by duners88 | Comments (0) | Permalink

AutoEventWireup and asp:Repeater

So for the last few days I have been scouring through lines and lines of code trying to figure out why the ASP Repeater control <asp:repeater ...> control was not working. 

I checked everything from the record set to the data binding to make sure I had covered all the bases.  Everything checked out but when I loaded the page the data was not displayed.

So in an attempt to troubleshoot the situation I created a new C# web form in VS 2005.  Keeping it simple I added just the one repeater control and data bound it to a single table.  Nothing fancy.  Loaded this page and it worked.

Over the next two days I methodically altered the non-functional page to be almost exactly like the functional page.  I was still having problems.  I even linked in the Master Page, CSS, and other supporting doc's to the functional page to see if it was something in one of them that was causing the problem.  I even altered the Page tag to point at the same CodeFile and still no Luck.

So then I paid a little more attention to this line... 

<%@ Page MasterPageFile="~/StandardLayout.master" Language="C#" AutoEventWireup="false" CodeFile="Default.aspx.cs" Inherits="Default" %>

It is at the top of every page, and I generally don't have reason to mess with it

Then I noticed that in the functional page the AutoEventWireup="true" and this attribute was missing from the non-functional page.

I added this attribute to the non-functional page and reloaded.  IT WORKS!!

So, what is AutoEventWireup and what does it do...

There is an excellent post at

http://odetocode.com/Blogs/scott/archive/2006/02/16/2914.aspx

Scott Allen gives you all the information you need as well as ways to deal with the different behaviors.

Basically my issue boiled down to the fact that the Page_Load event was not firing and so the data binding never occurred.

For performance reasons and not to break other pages I have set the AutoEventWireup to false and used Scott's work around.

Thank you Scott!!!

6. February 2008 11:54 by duners88 | Comments (0) | Permalink