Pages

Search

Monday, November 17, 2008

How to handle list box double click event in ASP.NET?

“ondblclick” client event available for list box control should be used to handle and post back or submit the page.

Where on page load event of the page , there should be sort of logic build to handle that this post back is because of double clicking the list box item.


In aspx Page :-


ondblclick="lstTableName _DoubleClick()">
1
2
3
4





In aspx.cs page

In page load event function

if (Request.Params["lstTableName_Hidden "] != null && (string)Request.Params["lstTableName_Hidden "] == "dblclk")
{ //logic whether to connect data base using the table name //selected in list box etc…
lstTableName.SelectedItem.Text
}

The hidden field “lstTableName_Hidden” value should be updated when client double event is fired such that after assigning flag to the hidden field through lstTableName _DoubleClick() function , it postbacks the page.
Where in page load event of the page we check the value of the lstTableName_Hidden value.
If it says the flag value it seems that the page postback has occurred just because of double clicking on the list box.

No comments:

Post a Comment