【发布时间】:2014-11-11 10:05:27
【问题描述】:
我遇到了一个问题。我在aspx 页面上放置了一个控件ascx。在 aspx 页面上,我使用的是UpdatePanel。在ascx 页面,我使用Formview。在Formview<InsertItemTemplate> 中,我使用控件asp:FileUpload 进行文件上传。选择文件后,当我检查FileUpload.HasFile 它总是给我假。我尝试解雇<Triggers> 但没有
成功,因为文件上传在我的ascx 页面上。在下面的示例中,我展示了我的问题部分。
code
FileUpload _fileUpload = FormView1.FindControl("FileUpload1") as FileUpload;
if (_fileUpload != null && _fileUpload.HasFile)
{
/// some code i write here
}
ASPX
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1" />
<asp:PostBackTrigger ControlID="imagAddNew" />
<asp:AsyncPostBackTrigger ControlID="EditProduct1" />
<asp:PostBackTrigger ControlID="ImageButton1" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnl_grid" Style="width: 100%; overflow: auto;" runat="server">
<uc1:EditProduct ID="EditProduct1" runat="server" />
</asp:Panel>
ASCX
<asp:FormView ID="FormView1" runat="server" Width="100%" ondatabinding="FormView1_DataBinding">
<InsertItemTemplate>
<table>
<tr>
<td class="label-col">
Image
</td>
<td class="data-col">
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
<td>
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="True" CommandName="Insert"
ImageUrl="~/images/save.gif" ValidationGroup="Inser" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:FromView>
【问题讨论】:
-
上传文件的按钮在哪里
-
@Ganesh_Devlekar 在 ascx 第一部分中用于文件上传的图像按钮
-
我发布了一个尝试 100% 工作的答案
-
@Ganesh_Devlekar 答案在哪里?我看不见
标签: c# asp.net file-upload updatepanel