views:

356

answers:

1

Hi all,

this my code in my user control's designer file

<%@ 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" />
                    &nbsp;
                    <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>

i am not getting Fiepath/name and Fileupload controls' posted file property is null i am checking fvFileUpload.Postedfile in click event of AddImageInfoButton

can anybody please tell me what i am doing wrong in this code... -thanks in advance

+1  A: 

File uploads are not supported in async postbacks, such as when you use the UpdatePanel. Read this blog post for more details.

Here are two proposed workarounds:

  1. Have a dedicated "Upload" button that does a regular postback instead of an async postback. You can achieve this using several techniques: Have the button be outside all UpdatePanels; have the button be the target of an UpdatePanel's PostBackTrigger; or call ScriptManager.RegisterPostBackControl() on it.
  2. Have a dedicated file upload page that doesn't have any UpdatePanels. Many web sites already do this anyway.
Eilon

related questions