Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Click event of a list box control

Reply
Thread Tools

Click event of a list box control

 
 
Scott
Guest
Posts: n/a
 
      12-30-2003
I have an asp.net page where I need to fill a grid when the user clicks
items in a list box control on the same page. There does not seem to be a
click event and the "onselectedindexchanged" item does not fire when the
user clicks on the items in the listbox.

Scott


 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      12-30-2003
hi scott,
Make sure you set the AutoPostBack property of the listbox to true,
otherwise it wont autopostback


"Scott" <(E-Mail Removed)-hc.com> wrote in message
news:%(E-Mail Removed)...
> I have an asp.net page where I need to fill a grid when the user clicks
> items in a list box control on the same page. There does not seem to be a
> click event and the "onselectedindexchanged" item does not fire when the
> user clicks on the items in the listbox.
>
> Scott
>
>



 
Reply With Quote
 
 
 
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      12-31-2003

Hi Scott,

The Click and SelectedIndexChanged are the server side events which can
fire when post back.
When you click items, the page will not postback to the server side, no
server side event will fire.
So just as Alessandro said, you should set the ListBox's AutoPostBack
property to true.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
Scott
Guest
Posts: n/a
 
      12-31-2003
Got it! Thanks!

Is there an equvilant way to hook a double-click event?

Scott

""Jeffrey Tan[MSFT]"" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Hi Scott,
>
> The Click and SelectedIndexChanged are the server side events which can
> fire when post back.
> When you click items, the page will not postback to the server side, no
> server side event will fire.
> So just as Alessandro said, you should set the ListBox's AutoPostBack
> property to true.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>



 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      01-02-2004

Hi Scott,

Thanks for your feedback.
The .Net listbox web server control does not encapsulate the double click
event(Actually, all the web controls do not encapsulate this event).
So we had to use the client script ondblclick event.
Sample code like this:
<script language="javascript">
function showitem()
{

alert(document.Form1["ListBox1"].options[document.Form1["ListBox1"].selected
Index].text );
}
</script>

private void Page_Load(object sender, System.EventArgs e)
{
ListBox lb=(ListBox)this.FindControl("ListBox1");
lb.Attributes.Add("OnDblClick","showitem()");
}

Note: The showitem() function is client side javascript code.

In the code above, I add the OnDblClick event handler in Page's Load event.
If you want to encapsulate this function into your ListBox server control,
you can override its Render method and add the OnDblClick event handler,
then render out your client side javascript code(i.e. showitem() function)

If you still have anything unclear, please feel free to let me know. I am
glad to work with you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When user press F5 after a button click event, the click event fires again! Max2006 ASP .Net 2 09-19-2007 05:37 AM
Wire up a click event within another click event doesn't work... Chu ASP .Net 2 04-10-2006 10:43 PM
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net Building Controls 1 05-28-2004 06:23 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM



Advertisments