Link to home
Start Free TrialLog in
Avatar of talker2004
talker2004Flag for United States of America

asked on

ASP.NET how can i disable the dropdown list during postback's to the server.

I am trying to disable the dropdown list only during postback operations to the server. In this example the server sleeps for 5 seconds to simulate server processing. Ideally i would like to block the end user from making a new selection while the server is processing. The solution must work with ie6, ie7, and firefox.


Thanks in advance

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
        If Not Page.IsPostBack Then
            Me.cboService.Items.Clear()
            Me.cboService.Items.Add("Hair Cut")
            Me.cboService.Items.Add("Manicure")
            Me.cboService.Items.Add("Perm")
        End If
    End Sub
    Protected Sub cboService_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        System.Threading.Thread.Sleep(5000)
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title runat="server" id="PageTitle">Default</title>  
<style type="text/css">
   BODY {
      background-color : #EACB9D;
      font-family : Tahoma;
      font-size : 9pt;
}
</style>
</head>
<body>

    <form id="form1" runat="server">
                <asp:Label ID="lblMessage1" runat="server" ForeColor="Blue" Height="24px" Text="(1) Select a Service & Employee"
                    Width="312px" Font-Size="Medium" style="left: 8px; position: absolute; top: 120px"></asp:Label>
                <asp:DropDownList ID="cboService" runat="server" Font-Size="Medium" Height="32px"
                    Width="312px" AutoPostBack="True" Font-Underline="False" style="position: absolute; left: 0px; top: 152px; z-index: 1;" OnSelectedIndexChanged="cboService_SelectedIndexChanged">
                    <asp:ListItem>Hair Cut</asp:ListItem>
                    <asp:ListItem>Massage</asp:ListItem>
                    <asp:ListItem>Manicure</asp:ListItem>
                </asp:DropDownList>
    </form>
</body>
</html>
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

<form id="form1" runat="server" onsubmit="document.getElementById('cboService).disabled = true;">

Sorry for the typo .

<form id="form1" runat="server" onsubmit="document.getElementById('cboService').disabled = true;">

ASKER CERTIFIED SOLUTION
Avatar of Pravin Asar
Pravin Asar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial