Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Click event of a list box control (http://www.velocityreviews.com/forums/t772178-click-event-of-a-list-box-control.html)

Scott 12-30-2003 10:39 PM

Click event of a list box control
 
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



Alessandro Zifiglio 12-30-2003 11:50 PM

Re: Click event of a list box control
 
hi scott,
Make sure you set the AutoPostBack property of the listbox to true,
otherwise it wont autopostback ;)


"Scott" <scott.schuman@nospam.ma-hc.com> wrote in message
news:%23JrbDXyzDHA.2440@TK2MSFTNGP12.phx.gbl...
> 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
>
>




Jeffrey Tan[MSFT] 12-31-2003 05:28 AM

RE: Click event of a list box control
 

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.


Scott 12-31-2003 10:56 PM

Re: Click event of a list box control
 
Got it! Thanks! :)

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

Scott

""Jeffrey Tan[MSFT]"" <v-jetan@online.microsoft.com> wrote in message
news:BtU4l71zDHA.3564@cpmsftngxa07.phx.gbl...
>
> 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.
>




Jeffrey Tan[MSFT] 01-02-2004 07:23 AM

Re: Click event of a list box control
 

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.



All times are GMT. The time now is 06:15 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.