-
Hourglass
I have 2 dropdown boxes and when a user make a selection on one the other gets populated with data. It take a few seconds to populate the 2nd dropdown but the form appears to look loaded. I want to prevent a user from making a selection in the 2nd dropdown until it is fully populated. Does anyone know how I can get around my problem? A hourglass might work but I don't know if it's possible to use with the server side script.
Thanks,
James
-
Given:
<select id="cboMyCombo">
<option></option>
<option>Sel</option>
<option>Sel 2</option>
</select>
<select id="cboTheOtherBox">
<option></option>
<option>Sel</option>
<option>Sel 2</option>
</select>
Then, in the ASPX page, you can do the following.
Code:
<script language="javascript" for="cboMyCombo" event="onpropertychange">
if(document.all){
document.all('cboTheOtherBox').style.display='none';
document.body.style.cursor="wait";
}else{
alert('please wait');
}
</script>
Make sure you put non-IE stuff in the else section. I think an alert is not appropriate, but other actions may be.
-
Also, do not change the onchange event. Dot-Net uses the onchange to keep track of controls.
That's why I choose to use the onpropertychange event.
-
Is this possible with a server side control? I'm still learning asp.net and I haven't use both client and server side script inside a server-side form. Can I use a HTML <select> tag inside a <form runat="server"></form>?
Thanks,
James
-
You can use it just fine.
If you want to add that code from the server, encapsulate it like this in a panel (lets say pnlTest)
pnlTest.Controls.Add(new LiteralControl("The script here"))