我想创建一个加载屏幕,但是当我触发selectedindexchanged时,代码将在同一时间执行所有代码,因此它只加载了很长时间,我想做的就是选择下拉菜单的选项,然后显示通过在页面加载过程中使“覆盖屏幕”可见,从而加载屏幕,我尝试了一些不同的操作,包括javascript和System.Threading.Thread.Sleep(22);
,但是没有运气,在此先感谢您的时间。
<div id="loading">
<div id="coverScreen" class="LockOn">
</div>
</div>
<asp:DropDownList ID="DropDown" DataValueField="IDCoContratante" DataTextField="Designation" runat="server" Enabled="true" CssClass="dropdownCocont" Style="border-radius: 7px; border-style: none;" AutoPostBack="true" OnSelectedIndexChanged="DropDown_ListarPropostas_SelectedIndexChanged"></asp:DropDownList>
protected void DropDown_ListarPropostas_SelectedIndexChanged(object sender, EventArgs e)
{
//Response.Write("<script>document.getElementById('coverScreen').style.visibility = 'visible';</script>");
coverScreen.Visible = true;
System.Threading.Thread.Sleep(22);
ClassConn c = new ClassConn();
c.OpenConection();
DataTable dt = new DataTable();
//SqlDataAdapter AtualizaDropLotes = new SqlDataAdapter(" SELECT dbo.TblLoteCoContratanteAdjudicado.IDLote, CAST(dbo.TblLote.NrLote AS varchar) + ' ' + dbo.TblLote.DescricaoLote AS DescricaoLote, dbo.TblLote.IDAcordoQuadro " +
// " FROM dbo.TblLoteCoContratanteAdjudicado INNER JOIN dbo.TblLote ON dbo.TblLoteCoContratanteAdjudicado.IDLote = dbo.TblLote.IDLote AND dbo.TblLoteCoContratanteAdjudicado.IDLote = dbo.TblLote.IDLote " +
// " WHERE (dbo.TblLote.IDAcordoQuadro = '" + DropDownAcordosQuadros_ListarPropostas.SelectedValue + "') " +
// " GROUP BY dbo.TblLoteCoContratanteAdjudicado.IDLote, CAST(dbo.TblLote.NrLote AS varchar) + ' ' + dbo.TblLote.DescricaoLote, dbo.TblLote.IDAcordoQuadro", c.con);
string _query = "SELECT '%' as IDLote, 'Todos' as DescricaoLote UNION ALL SELECT CAST(dbo.TblLoteCoContratanteAdjudicado.IDLote AS VARCHAR), 'Nº' + CAST(dbo.TblLote.NrLote AS varchar) + ' - ' + dbo.TblLote.DescricaoLote AS DescricaoLote FROM dbo.TblLoteCoContratanteAdjudicado INNER JOIN dbo.TblLote ON dbo.TblLoteCoContratanteAdjudicado.IDLote = dbo.TblLote.IDLote AND dbo.TblLoteCoContratanteAdjudicado.IDLote = dbo.TblLote.IDLote WHERE(dbo.TblLoteCoContratanteAdjudicado.NIFCoContratante = '" + id_Vat + "') AND(dbo.TblLote.IDAcordoQuadro = '" + DropDownAcordosQuadros_ListarPropostas.SelectedValue + "')";
SqlDataAdapter AtualizaDropLotes = new SqlDataAdapter(_query, c.con);
AtualizaDropLotes.Fill(dt);
if (dt != null)
{
DropDownLotes_ListaPropostas.DataSource = dt;
DropDownLotes_ListaPropostas.DataBind();
}
c.CloseConnection();
coverScreen.Visible = false;
}
答案 0 :(得分:0)
根据Alex Kudryashev和Gus给我的信息,我能够找到解决问题的方法,就是:
我将加载屏幕插入了asp:UpdatePanel之间,顶部是asp:ScriptManager。
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<div id="coverScreen" class="LockOn" runat="server">
</div>
</ProgressTemplate>
</asp:UpdateProgress>
然后我在主div中插入了以下代码
<div id="Main">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
//your code
</ContentTemplate>
</asp:UpdatePanel>
</div>