Petey B
Petey B

Reputation: 11569

ASP.Net dropdownlist post back on lose focus?

Right now I'm using the OnSelectedIndexChanged event to trigger a post back and update some other fields in the form. That works fine. But I would like it to do the post back when the drop down list loses focus, rather than on every change. The problem is, when someone selects the list, then types a number, it will change with every key stroke they press, and that will trigger the post back before they get to the value they are trying to type.

Is this possible?

Upvotes: 1

Views: 4952

Answers (2)

janhartmann
janhartmann

Reputation: 15003

Try this.

ddlDropDown.Attributes.Add("onblur", "__doPostBack('ddlDropDown','');");

I have not tested it, but I believe it will work - or I hope.

Upvotes: 3

Widor
Widor

Reputation: 13275

The JavaScript event for something losing focus is called onblur.

Use Attributes.Add() in server-side code to add the function name to be called. You can then trigger the postback from said function.

Upvotes: 3

Related Questions