Multiple events on post-back
-
I am facing a unique problem (looks unique to me at least). I have a dropdown whose auto-postback is enabled. User can select a value from the dropdown to go to another page. But when the user comes back to original page by clicking the back button on the browser and clicks any button then on the post-back caused by the button, first the "SelectedIndexChanged" event handler of that dropdown is called then the "Click" event handler of this button is called. Hope I have explained the problem clearly. Can anyone tell me what's going wrong and how to solve the issue?
-
I am facing a unique problem (looks unique to me at least). I have a dropdown whose auto-postback is enabled. User can select a value from the dropdown to go to another page. But when the user comes back to original page by clicking the back button on the browser and clicks any button then on the post-back caused by the button, first the "SelectedIndexChanged" event handler of that dropdown is called then the "Click" event handler of this button is called. Hope I have explained the problem clearly. Can anyone tell me what's going wrong and how to solve the issue?
Just put the code that you have written for redirect to different page of Dropdownlist SelectedIndexChanged.
cheers, Abhijit CodeProject MVP
-
I am facing a unique problem (looks unique to me at least). I have a dropdown whose auto-postback is enabled. User can select a value from the dropdown to go to another page. But when the user comes back to original page by clicking the back button on the browser and clicks any button then on the post-back caused by the button, first the "SelectedIndexChanged" event handler of that dropdown is called then the "Click" event handler of this button is called. Hope I have explained the problem clearly. Can anyone tell me what's going wrong and how to solve the issue?
om pr wrote:
Can anyone tell me what's going wrong and how to solve the issue?
I suspect that what is happening is that when you go back the browser remembers the state of the controls when you originally left the page and sets them to those values. However, this time the value change for the drop down does not trigger a post back. When you press the button the postback is triggered. The server then compares what is in the viewstate with what the controls now look like and raise events for any changes. Because it sees two changes (the drop down and the button click) those events are raised. A possible route to solving the issue is to turn off the viewstate (which also means you won't get change events, although you will still get button click events) and detect the drop down change yourself rather than rely on ASP.NET.
*Developer Day Scotland - Free community conference Delegate Registration Open
-
Just put the code that you have written for redirect to different page of Dropdownlist SelectedIndexChanged.
cheers, Abhijit CodeProject MVP
I did the same but it is not working......looks like the browser is remembering the previous state of the page and so is causing the previous event to be raised in addition the present event..... I think I have to take help of javascript. Thank for the reply
-
om pr wrote:
Can anyone tell me what's going wrong and how to solve the issue?
I suspect that what is happening is that when you go back the browser remembers the state of the controls when you originally left the page and sets them to those values. However, this time the value change for the drop down does not trigger a post back. When you press the button the postback is triggered. The server then compares what is in the viewstate with what the controls now look like and raise events for any changes. Because it sees two changes (the drop down and the button click) those events are raised. A possible route to solving the issue is to turn off the viewstate (which also means you won't get change events, although you will still get button click events) and detect the drop down change yourself rather than rely on ASP.NET.
*Developer Day Scotland - Free community conference Delegate Registration Open
Thanks for the reply Colin, I tried all possible options including disabling the viewstate as suggested by you but it all failed. I just managed to solve the issue with the help of javascript. Instead of sending the user to the next page via Response.Redirect on the index change of the dropdown, I am now doing the same with the help of simple javascript i.e. window.location.href. Thanks again for the reply, appreciate it!
-
Thanks for the reply Colin, I tried all possible options including disabling the viewstate as suggested by you but it all failed. I just managed to solve the issue with the help of javascript. Instead of sending the user to the next page via Response.Redirect on the index change of the dropdown, I am now doing the same with the help of simple javascript i.e. window.location.href. Thanks again for the reply, appreciate it!
What happens if the user has disabled javascript?
*Developer Day Scotland - Free community conference Delegate Registration Open
-
What happens if the user has disabled javascript?
*Developer Day Scotland - Free community conference Delegate Registration Open
I our case this will not happen because whole site is javascript dependent. If it is disabled then nothing will work and moreover the site is for Intranet use and user of this site will not have the flexibility to turn the javascript setting of the browser on or off at will. But this question still remains. What if the site were for general public on the Internet? In that case what could be the solution if even javascript could not solve it? Any idea!!
-
I did the same but it is not working......looks like the browser is remembering the previous state of the page and so is causing the previous event to be raised in addition the present event..... I think I have to take help of javascript. Thank for the reply
om pr wrote:
I did the same but it is not working....
:doh: But I didn't suggested you to do any thing. I have just asked you to put those selected index change code.
cheers, Abhijit CodeProject MVP
-
om pr wrote:
I did the same but it is not working....
:doh: But I didn't suggested you to do any thing. I have just asked you to put those selected index change code.
cheers, Abhijit CodeProject MVP
-
I am facing a unique problem (looks unique to me at least). I have a dropdown whose auto-postback is enabled. User can select a value from the dropdown to go to another page. But when the user comes back to original page by clicking the back button on the browser and clicks any button then on the post-back caused by the button, first the "SelectedIndexChanged" event handler of that dropdown is called then the "Click" event handler of this button is called. Hope I have explained the problem clearly. Can anyone tell me what's going wrong and how to solve the issue?
Is this happening only one one machine? Can you reproduce it on another machine. Today, I spent 30 minutes on non-issue with my boss's machine. The browser had old cached copy and clearing the cache *fixed* the issue.
Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]