Wednesday, March 21, 2012

A postback via update panel resets TabIndex?

I have a few controls inside an update panel. One of them is a dropdownlist with autopostback = true. After it postbacks (you know in Ajax style, no full page postback) the the tab indexes of the controls seem to get ignored or reset. I end up back at the first control in the tab index or else sometimes no control is focused when hitting the tab key.

Anyone find the same issue?

There's a workaround I found, just in case you're using ASP.NET Ajax.

In my example, I have a FormView and two DropDownLists, the first is called "ddlCountries", with AutoPostBack=True. The second is called "ddlStates".

In my case, my page is using an ScriptManager. And my FormView is inside an UpdatePanel.


Just create an event for the "ddlCountries" as follows:

protected void ddlCountries_SelectedIndexChanged(object sender, EventArgs e){DropDownList ddlStates = (DropDownList)FormView1.FindControl("ddlStates");ScriptManager1.SetFocus(ddlStates);}

And voi-là!!


Thanks I found that solution too, its a pity the tabindex settings are ignored with partial postacks in ASP.net Ajax.

No comments:

Post a Comment