Thursday, March 22, 2012

Serious and stupid problem..

Hi.

I'm using ASP.NET 1 .1 with C#..

My problem is very weird..I have a listbox and a button ,both are WebControls..

When I clicked on an item in Listbox code fires ListBox_SelectedItemChanged event and navigates to a new page. Until this part it works fine.

When I goto back by browsers BACK button anc click the Button ListBox_SelectedItemChanged fires again.Strange isn' t it??

Has anyone had this problem before?

I have checked the event handlar declarations and they are correct.

tguclu,

It is not strange behaviour. If you use BACK button , the page view comes from IE history. When you do a postback this page ( Buton click..etc..) ,SelectedItemChangedevent will fire because there is a change in index after intial load.

To avoid the problem, you can try this..

In page_Load..

if (!IsPostBack)

{

//***** Reset the Listbox selected index *********

MyListBox.SelectedIndex= 0;

}

0 comments:

Post a Comment