0

当我从下拉列表中选择项目并上传图像时,我正在尝试制作我的应用程序,它不会刷新整个页面而只是刷新更新的部分。下面显示的代码适用于下拉列表,但不适用于上传按钮。当我上传图片时,页面保持刷新。请帮我看看我做错了什么,或者我忘记添加任何内容。谢谢!

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>

<asp:DropDownList ID="ddlPoliceID" runat="server"
            AutoPostBack="True" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlPoliceID_SelectedIndexChanged">
            <asp:ListItem Value="-1">--Select--</asp:ListItem>
            </asp:DropDownList>

<asp:Label ID="Label10" runat="server" Text="Rank:"></asp:Label>
            <br />
            <asp:Image ID="Image2" runat="server" />
            <br />
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <br />
            <asp:Button ID="btnUpload1" runat="server" Text="Upload" OnClick="btnUpload1_Click" />
            <br />
            <asp:Label ID="lblUpload1" runat="server" Text=""></asp:Label>
            <br />

 </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ddlPoliceID" EventName="SelectedIndexChanged" />
        <asp:PostBackTrigger ControlID="btnUpload1" />
    </Triggers>
    </asp:UpdatePanel>
4

1 回答 1

0

此处的代码以粗体显示是您想要的。

--Select-- --Foo-- --Bar-- --Goo--

    <asp:Label ID="Label10" runat="server" Text="Rank:"></asp:Label>
    <br />
    <asp:Image ID="Image2" runat="server" />
    <br />
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <br />
    <asp:Button ID="btnUpload1" runat="server" Text="Upload" OnClick="btnUpload1_Click" />
    <br />
    <asp:Label ID="lblUpload1" runat="server" Text=""></asp:Label>
    <br />
 </ContentTemplate>
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="ddlPoliceID" EventName="SelectedIndexChanged" />
    **<asp:AsyncPostBackTrigger ControlID="btnUpload1" EventName="Click" />**
</Triggers>
</asp:UpdatePanel>
于 2013-07-17T06:49:12.783 回答