views:

1136

answers:

5

I have inherited an ASP.NET 2.0 project and one of the things I have noticed is that the user has to click a dropdownlist twice in order to expand it - why is this?

Sequence of Events

  1. The first click with give the control focus and the second will expand it.
  2. The application uses Master/Content pages and is Ajax enabled.

It looks like this doesn't happen in IE6, but does happen in IE7.

A: 

dunno if this is the best solution and haven't tried it .. but how about setfocus at onload() to the control in question ?

Scott Evernden
Thanks for the suggestion but it's a non-starter as SetFocus can only be called before and during PreRender (apparently).
DilbertDave
A: 
Gavin Miller
The code is a bit all over the place as it is split between master pages, content pages and user controls. I have just dropped a DDL onto an existing page and added a couple of items manually (no event handling at all) and it too requires two clicks to expand it. :-(
DilbertDave
A: 

Is the drop-down data being populated in the on-drop-down event? If so, an easy fix would be to set the DroppedDown state to True at the end of the data load.

JosephStyons
He's using ASP.NET, not winforms
Gavin Miller
Oh yeah. I feel stupid now.
JosephStyons
+1  A: 

Found it and sorted it (for now).

The problem was being caused by a Javascript function that was inserted by a usercontrol and was adding styling to the DropDownLists. Why this was not done in CSS I have no idea (but it will be shortly) but commenting out the following function resolved my problem:

    function inputOnFocus(objInput)
    {
        objInput.style.backgroundColor = sHighLightBgColor;
        objInput.style.border = sBorderHighlight;

        //objInput.className = "inputOnFocus";
        sIDWithFocus = objInput.id;
    }

I'm not quite sure how/why this was being applied to some DDLs and not others but at the moment (with a customer demo coming up) I don't really care - I'll dig into that when I get a chance.

Thanks @LFSR Consulting, @Scott Evernden and @kogus for your input.

DilbertDave
A: 

I know I'm posting on an old thread; however, I would like to share my two cents on this as it may assist anyone in the future.

I was recently working on a quick form and wanted to highlight all the fields that a user would go to with yellow, and obviously go back to white when the focus was lost.

Without going into code, since i'm not working with ASP.NET, just the javascript portion...what I did to remedy this was create another event for onmousedown. By just having the onfocus section it would result in me having to click twice into a drop-down box. Once to set the focus, another to click and list the items. By adding the onmousedown function, it then allowed my color changes to take place upon clicking as well as a tab or other form of focus shift.

Of course, there's no need to have a counterpart, as the onblur took care of it (the counterpart of onfocus).

Etchavious