ThanksLike when using a chat like messenger.
Maybe this will work -- ? It inserts new items and then selects them, effectively moving the scrollbar down. Not sure if selecting them works for you. The button first inserts a new item (just the current date/time) and then injects client script into the page to cause the last item to be selected.
<%@. Page Language="VB" %>
<script runat="server">
Sub buttonAdd_Click(senderAsObject, eAs EventArgs)
ListBox1.Items.Add( DateTime.Now.ToString() )
Dim scrollScriptAsString
scrollScript &="<script language='javascript'>"
scrollScript &="document.forms[0].ListBox1.selectedIndex " & _
" = document.forms[0].ListBox1.options.length-1;"
scrollScript &="<" &"/" &"script>"
Page.RegisterStartupScript("", scrollScript)
EndSub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:ListBox id="ListBox1" runat="server"></asp:ListBox>
</p>
<p>
<asp:Button id="buttonAdd" onclick="buttonAdd_Click" runat="server" Text="Add"></asp:Button>
</p>
</form>
</body>
</html>
Thanks
0 comments:
Post a Comment