Phillip Andrews
Phillip Andrews

Reputation: 49

ASP open dropdown from code behind

I have a drop down that will open using example code from. https://jsfiddle.net/fz2sY/39/. However if I call the same function from code behind. ScriptManager.RegisterStartupScript(this, this.GetType(), "","runThis(dropdown);", true);

The dropdown is inconsistant and opens sometimes but more often fails. Is there anything that can be changed in the code behind to make the function call more reliable?

Upvotes: 1

Views: 980

Answers (1)

Anant Dabhi
Anant Dabhi

Reputation: 11104

You need to call ShowDropdown function after window load

ScriptManager.RegisterStartupScript(this, this.GetType(), "","window.onload = function(){ showDropdown(document.getElementById('dropdown'));}", true);

Upvotes: 1

Related Questions