Archive

Posts Tagged ‘.NET’

JavaScript Form Posting and Firefox

August 3, 2010 Leave a comment

While working on a .NET form today, I needed to add postback functionality to a Gridview control, using standard HTML radio buttons instead of traditional buttons (I had to confirm that a value was selected and if so, highlight the row).

So I assembled a prototype that implemented two hidden input fields. One held the radio group ID, and the other held the RowIndex value for the Gridviewrow; I needed these two pieces of information in order to flag the button as ‘checked’ as well as color the correct row.

So I whipped up a simple script:

function setPBItem(formItem, rowVal)
{
form1.hdnPBItem.value = formItem;
form1.hdnPBRowValue.value = rowVal;
form1.submit();
}

Works fine in IE 7, as well as Google Chrome… but it did not work at all in Firefox.

A little digging around led me to a few posts where others complained about the same problem in Firefox – although this is sound DOM syntax, none of it worked in Firefox.

However, changing it to this got it working:

function setPBItem(formItem, rowVal)
{
document.forms["form1"].hdnPBItem.value = formItem;
document.forms["form1"].hdnPBRowValue.value = rowVal;
document.forms["form1"].submit();
}

The difference here is simply adding the fully qualified DOM syntax. But apparently you also have to specify the form’s name; the index did not work in Firefox either.

Form submits just fine now. Something to keep in mind when implementing similar functionality.

Carolina Code Camp 2010 Wrap-Up

May 16, 2010 Leave a comment

Carolina Code Camp LogoThanks very much to the volunteers, speakers, and sponsors for this past weekend’s Car0lina Code Camp in Charlotte. I wish I could have cloned myself so that I could attend all the sessions. I did get to do some work with MVC 2 and XNA (the “end product” demo was not quite working, but I had a chance to do some tweaking to get it running), but for me the prize for the day’s best session went to Michael Norton’s stellar presentation on Technical Debt. This 45 minute presentation discusses the penalties associated with writing sloppy code, among other bad habits and pitfalls, that ultimately lead developers to incurring large “debt” that is paid back in one form or another later in a project’s development cycle. Highly recommended.

Also had a chance to sit down and briefly chat with Joe Audette, founder and architect of mojoPortal. It was kismet, my running into him – I followed him into an elevator and noticed he was wearing a mojoPortal T-shirt. When I asked him about it (I was curious to know what his opinion of the CMS was, since we are evaluating them right now and that’s on our review list), he smiled and mentioned that he “wrote it”. I was surprised, and we chatted for a while in the registration line, me burning his ear with some discussion of other CMS products. After he clarified some misconceptions I had about his product, I left with a much better understanding of his work. We should be reviewing it this week.

Categories: Development Tags: ,
Follow

Get every new post delivered to your Inbox.