2015-05-07 27 views
1

我有一個下拉菜單,將使用示例代碼打開。 https://jsfiddle.net/fz2sY/39/。 但是,如果我從後面的代碼調用相同的功能。 ScriptManager.RegisterStartupScript(this, this.GetType(), "","runThis(dropdown);", true);從後面的代碼ASP打開下拉菜單

下拉列表不一致,有時會打開,但更常失敗。 是否有任何可以在代碼後面進行更改以使函數調用更可靠?

+0

將其更改爲的RegisterClientScriptBlock後ShowDropdown功能。 – Mairaj

+0

你在說背後的代碼 - 當然這是asp.net而不是經典asp – John

+0

對不起約翰,剛剛編輯。 –

回答

1

你需要調用窗口負載

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

謝謝,作品一種享受。 –