に次の JavaScript を登録しますPage_Load()
。
var scriptReihe = "<script type=\"text/javascript\">function OnClientLoadHandlerReihe(sender) {"
+ "var listbox = $find(\"" + lbReihen.ClientID + "\");"
+ "var item = listbox.get_selectedItem();"
+ "item.ensureVisible();"
+ "}"
+ "</script>";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "OnClientLoadHandlerReihe", scriptReihe);
lbReihen.OnClientLoad = "OnClientLoadHandlerReihe";
はどこlbReihen
ですかRadListBox
これはうまく機能selectedItem
しており、ListBox の表示領域にあります。
ページには、次のボタンもあります。
<asp:Button ID="myBtn" runat="server" Text="Call google" OnClientClick="window.open('http://www.google.ch', '_blank');" />
問題は、ボタンがクリックされて新しいページが(新しいタブで)開かれると、ListBoxがブロックされることです。スクロールできないなど。
の EventHandler を登録しないとOnClientLoad
、すべてうまくいきます。
何が間違っているのか、誰かが私にヒントを与えることができますか? - ありがとう。