页面在下拉列表更改时闪烁

时间:2014-05-12 10:11:13

标签: c# asp.net .net flicker

我正在使用下拉列表来选择客户。页面在选择客户时闪烁两次,我不知道如何纠正它。有人可以帮我解决问题吗?

我的下载SelectedIndexChange代码

protected void ReceiverDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
    if (ReceiverDropDown.SelectedValue != null && ReceiverDropDown.SelectedValue != "0")
    {            
        string benId = ReceiverDropDown.SelectedValue;
        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "AddDetails('" + benId + "');", true);
    }
}

使用更新面板的代码

<td>
    <asp:UpdatePanel runat="server" ID="updTerms" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:DropDownList Width="180px" CssClass="select_quo_one" ID="ReceiverDropDown" 
                runat="server" AutoPostBack="true"
                OnSelectedIndexChanged="ReceiverDropDown_SelectedIndexChanged">
            </asp:DropDownList>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </ContentTemplate>
    </asp:UpdatePanel>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ReceiverDropDown" />
    </Triggers>
</td>

enter image description here

2 个答案:

答案 0 :(得分:0)

为避免页面闪烁,您可以使用更新面板。将DropDownList绑定在更新面板中。

<强>标记:

<asp:UpdatePanel runat="server" ID="updTerms">
    <ContentTemplate>
        <asp:DropDownList ID="ReceiverDropDown" runat="server">
    </asp:DropDownList>
    </ContentTemplate>
    <Trigger>
        <asp:AsyncPostBackTrigger ControlID="ReceiverDropDown"  />
    </Trigger>
</asp:UpdatePanel>

答案 1 :(得分:0)

使用更新字段,如:

<asp:UpdatePanel ID="updpnlRefresh" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:TextBox ID="txtQuantity"  runat="server" Width="50px"
                     onkeydown="ClearErrorMessages()" onkeypress="return allowNumeric(event)"
                     ontextchanged="txtQuantity_TextChanged"  Text='<%#Eval("Quantity") %>'
                     AutoPostBack = "true"  ondragstart="return false;"
                     ondrop="return false;" />               
    </ContentTemplate>
</asp:UpdatePanel>