I have an ASP NET page with a dropdownlist. When the user select an item, a postback occurs, but it takes some time to receive the response, due to server processing. I want to show a label ‘wait, reading data’ or something, on the client side while waiting for the response.
Have tried some samples but nothing, any help?
this, does not work
<script type="text/javascript" language="javascript">
function ShowConfirm(obj) {
document.getElementById("<%=Lbl_Buscar.ClientID%>").style.display = "none";
__doPostBack(obj.id, '');
}
</script>
2
Answers
Thanks for your detailed response. The solution isnt working for me, after select the item in the dropdown, the page does not postback, not even display the mesage. I think it is because is inside a panel with a modalpopup extender. In fact, for the dropdown to work, I have to remove the onchange part.
Actually, you can do this very easy with a button click, or in your case a dropdown.
The simple trick is that a button click, or even a dropdown can have BOTH a client side event, and the server side event.
This works for a button, or in this case a drop down.
so say this markup:
We have a dropdown list (combo box), then a "div" with text, picture (animated gif), or whatever for the please wait message.
but, note how we have both a client side, and server side event for the drop down list.
So, code behind is really simple. (since the post-back WHEN complete will re-load the page – and thus re-hide our message).
So, code behind is this:
So, we "fake a 2 second delay
the result is thus this:
So, all you do is add a "div" with say a spinner and some text like "please wait…".
And note how ZERO changes was required to the server side (code behind) here.
I do this all the time for buttons, and the approach is just the same.
Eg this:
note how for the button, we MUST return "true" for the server side event to run. (and this feature can be rather handy, since you can then launch a js "confirm" dialog, and if the user hits no then you return false, and the server side button click does not run. Great for say a delete button.