ImDaFrEaK
Well-known member
How can I get a postback when someone double clicks an item in a listbox.
Sorry I am new to ASP and trying to get it down pat.
Sorry I am new to ASP and trying to get it down pat.
[SIZE=2]ListBox1.Attributes.Add([/SIZE][SIZE=2][COLOR=#800000]"ondblclick"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"javascript:dbl()"[/COLOR][/SIZE][SIZE=2])[/SIZE]
<script type ="text/javascript">
function dbl() {document.forms[0].submit()}
</script>
[SIZE=2][SIZE=2]ListBox1.Attributes.Add([/SIZE][SIZE=2][COLOR=#800000]"ondblclick"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"javascript:dbl("[/COLOR][/SIZE][SIZE=2] & ListBox1.ClientID & [/SIZE][SIZE=2][COLOR=#800000]")"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[/SIZE]
<script type ="text/javascript">
function dbl(ctl) {__doPostBack(ctl, "");}
</script>
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ListBox1_SelectedIndexChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ListBox1.SelectedIndexChanged
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] IsPostBack [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ListBox1.SelectedIndex < 0 [/SIZE][SIZE=2][COLOR=#0000ff]OrElse[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ListBox1.SelectedItem.ToString = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]Response.Clear()
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] FI [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] FileInfo([/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ListBox1.SelectedItem.ToString)
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Title = FI.Name
Response.AppendHeader([/SIZE][SIZE=2][COLOR=#800000]"content-disposition"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#800000]"attachment; filename="[/COLOR][/SIZE][SIZE=2] & FI.Name)
Response.ContentType = [/SIZE][SIZE=2][COLOR=#800000]"text/plain"
[/COLOR][/SIZE][SIZE=2]Response.WriteFile([/SIZE][SIZE=2][COLOR=#800000]"C:\Music\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ListBox1.SelectedItem.ToString)
Response.Flush()
Response.End()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].ListBox1.SelectedIndex = -1
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]