<p>
<asp:ListBox id='ListBox1' runat='server'></asp:ListBox>
</p>
<p>
<asp:Button id='buttonAdd' runat='server' Text='Add'></asp:Button>
</p>
In button Click Event
VB.NET
ListBox1.Items.Add(DateTime.Now.ToString('MMM dd, yyyy') + ' ' + DateTime.Now.ToString('t'))
Dim scrollScript As String
scrollScript &= '<script language=’javascript’>'
scrollScript &= 'document.forms[0].ListBox1.selectedIndex ' & _
' = document.forms[0].ListBox1.options.length-1;'
scrollScript &= '<' & '/' & 'script>'
Page.RegisterStartupScript('', scrollScript)
C#
ListBox1.Items.Add(DateTime.Now.ToString('MMM dd, yyyy') + ' ' + DateTime.Now.ToString('t'));
string scrollScript='' ;
scrollScript += '<script language=’javascript’>';
scrollScript += 'document.forms[0].ListBox1.selectedIndex = document.forms[0].ListBox1.options.length-1;';
scrollScript += '<' + '/' + 'script>';
Page.RegisterStartupScript('', scrollScript);
Share with