Within the Page_Load()
function, I am adding the following JavaScript:
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";
The variable lbReihen
represents a control of type RadListBox
.
This script works perfectly as intended, ensuring that the selected item in the ListBox is visible.
In addition to the ListBox, there is also a button on the page:
<asp:Button ID="myBtn" runat="server" Text="Call google" OnClientClick="window.open('http://www.google.ch', '_blank');" />
However, an issue arises when this button is clicked and a new tab containing Google is opened. After this action, the ListBox becomes unresponsive, making it impossible to scroll or interact with it.
If I remove the EventHandler registration for OnClientLoad
, everything functions correctly again.
Could someone offer some guidance on what might be causing this issue? Any help would be appreciated - thank you.