我的用户控件的设计器文件中的代码
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucImageList.ascx.cs"
Inherits="Pariwaar.UserControl.ucImageList" %>
<asp:ScriptManagerProxy ID="ajaxScriptManagerProxy" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:HiddenField ID="hidUserId" runat="server" />
<asp:HiddenField ID="hidAlbumId" runat="server" />
<table>
<tr>
<td>
<asp:FileUpload ID="fvUploadFile" runat="server" EnableViewState="true" />
<asp:LinkButton ID="AddImageInfoButton" CssClass="blueLink" runat="server" Text="Upload"
OnClick="AddImageInfoButton_Click"></asp:LinkButton>
</td>
</tr>
<tr>
<td>
<asp:DataList ID="DtLstImageList" runat="server" DataSourceID="odsImageList" OnItemCommand="DtLstImageList_ItemCommand"
EnableTheming="true" RepeatColumns="4" RepeatDirection="Horizontal">
<ItemTemplate>
<ul>
<li style="display: block; text-align: center;">
<asp:ImageButton ID="ImgBtnImagePath" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImagePath")%>'
ImageAlign="Middle" Width="100" Height="100" CommandName="ViewImage" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ImageId")%>' />
</li>
<li style="display: block;">
<asp:Button ID="UpdateCoverPageImage" runat="server" Text="Set as Cover Page" CssClass="inputButtonWithoutpadding"
CommandName="SetAsCoverPage" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ImageId")%>' />
</li>
</ul>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ObjectDataSource ID="odsImageList" runat="server" SelectMethod="GetImageInfo"
TypeName="Pariwaar.Controller.GallaryHandler" DeleteMethod="DeleteImageInfo">
<DeleteParameters>
<asp:Parameter Name="ImageId" Type="Int64" />
</DeleteParameters>
<SelectParameters>
<asp:Parameter DefaultValue="0" Name="ImageId" Type="Int64" />
<asp:ControlParameter ControlID="hidAlbumId" Name="AlbumId" PropertyName="Value"
Type="Int64" DefaultValue="0" />
</SelectParameters>
</asp:ObjectDataSource>
我没有得到Fiepath / name,而Fileupload控件的发布文件属性为null 我在AddImageInfoButton的点击事件中检查fvFileUpload.Postedfile
任何人都可以告诉我这段代码我做错了什么...... - 提前谢谢
答案 0 :(得分:2)
异步回发不支持文件上传,例如使用UpdatePanel时。有关详细信息,请阅读此blog post。
以下是两个建议的解决方法: