Double Click on Listbox

T

tshad

Is there a way to do go to an even using double click?

I know there is such an event, but I haven't seen any on the asp.net
objects.

I tried to add one, but it didn't go anywhere.

Thanks,

Tom
 
J

Jody Gelowitz

I believe that you will need to use JavaScript to do this.

'CodeBehind
Me.ListBox1.Attributes.Add("onDblClick", "lstDblClicked")

'JavaScript function
<script language='javascript'>
function lstDblClicked(){
for (var i = 0; i < document.forms[0].ListBox1.options.length; i++ {
if (document.forms[0].ListBox1.options.selected) {
...
}
}
}
</script>

HTH,
Jody
 
T

tshad

Jody Gelowitz said:
I believe that you will need to use JavaScript to do this.

'CodeBehind
Me.ListBox1.Attributes.Add("onDblClick", "lstDblClicked")

'JavaScript function
<script language='javascript'>
function lstDblClicked(){
for (var i = 0; i < document.forms[0].ListBox1.options.length; i++
{
if (document.forms[0].ListBox1.options.selected) {
...
}
}
}
</script>


That was what I was looking for, but I needed to go farther. I needed to
get back to my asp code and found a way to do that using Javascript as you
suggested.

What I did was:

sub Page_load(s as object,e as eventargs)
if not IsPostBack then
Me.StoredResumes.Attributes("ondblClick") =
"__doPostBack('LbxSender','')"
end if
If Request.Form("__EVENTTARGET") = "LbxSender" Then
Dim strSelected As String
strSelected = StoredResumes.SelectedItem.Value.ToString
Call SelectResume(strSelected)
End If
end sub

Works pretty well, so far.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top