更改没有刷新页面的DropDownList列表并在asp.net中进行fileupload

时间:2018-09-20 20:34:38

标签: asp.net file-upload visual-studio-2015 updatepanel

我将UpdatePanel控件用于更改DropDownList项目中的不刷新页面。另外,我在UpdatePanel控件之外使用FileUpload。

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode= "Conditional">
                <ContentTemplate>
            <div class="form-group">
                <label class="control-label col-sm-2">
                    Country:
                            <span class="text-danger">*</span>
                </label>
                <div class="col-sm-4">
                    <asp:DropDownList ID="ddlCountry" ClientIDMode="Static" runat="server" CssClass="dropdown" ViewStateMode="Enabled" DataTextField="Value" DataValueField="Key" Autopostack="True" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged"></asp:DropDownList>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">
                    City:
                </label>
                <div class="col-sm-10">
                    <asp:DropDownList ID="ddlCity" ClientIDMode="Static" DataTextField="Title" DataValueField="CityID" runat="server" CssClass="form-control" ViewStateMode="Enabled" />
                </div>
            </div>
            </ContentTemplate>  
            </asp:UpdatePanel>
<div class="form-group">
                    <label class="control-label col-sm-4">
                        Image:
                    </label>
                    <div class="col-sm-8" style="padding-top: 5px;">
                        <asp:FileUpload ClientIDMode="Static" ID="fuPic" runat="server" ViewStateMode="Enabled" />
                    </div>
                </div>

但是它对于更改DropDownList项目无效。

1 个答案:

答案 0 :(得分:0)

好像没有触发更新,请尝试将autopostBack =“ True”添加到下拉列表中 编辑:您的aspx代码看起来应该可以工作,问题可能出在代码隐藏区中。 编辑:您也可以尝试将显式触发器添加到updatepanel。 尝试添加触发器,我更正了自动回发的拼写。

相关问题