Greetings.. and thanks for reading my post.
Using the control more or less "out of the box" in the manual upload files example. Only difference from official example and mine, is that i'm using it in a usercontrol context.
Everything seems to work fine (lists out items to be uploaded etc.etc.) but when pressing "Submit" the "AttachmentItemCollection" doesn't have any items inside.. Not sure if it's the usercontrol or what but here is the structure of the page :
So to summarize : CuteWebUi.AttachmentItemCollection.Count = 0 even though items are listed out in the listbox for "to-be-processed".
Anyone have any ideas on this ?
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<Triggers>
<asp:PostBackTrigger ControlID="lnkUploadDocument" />
<asp:PostBackTrigger ControlID="lnkCancel" />
<asp:PostBackTrigger ControlID="LnkForsideDokument" />
</Triggers>
<ContentTemplate>
<asp:Panel runat="server" ID="pnlUploadCtrl">
<table class="upload-document-table">
<tr>
<td class="td-text">Last opp dokument</td>
<td>
<CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader1"
InsertText="Bla gjennom filer" OnFileUploaded="Uploader_FileUploaded">
<ValidateOption MaxSizeKB="1024" />
</CuteWebUI:UploadAttachments>
<p>
<asp:Button runat="server" ID="SubmitButton" Text="Last opp" OnClick="SubmitButton_Click" />
</p>
<p>
<asp:ListBox runat="server" ID="ListBoxEvents" />
</p>
<%--<asp:FileUpload runat="server" ID="fuplDocument" />--%>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Here are the back-end methods :
void InsertMsg(string msg) { ListBoxEvents.Items.Insert(0, msg); ListBoxEvents.SelectedIndex = 0; }
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
SubmitButton.Attributes["onclick"] = "return submitbutton_click()";
}
protected void SubmitButton_Click(object sender, EventArgs e)
{
InsertMsg("You clicked the Submit Button.");
InsertMsg("You have uploaded " + uploadcount + "/" + Uploader1.Items.Count + " files.");
}
int uploadcount = 0;
protected override void OnPreRender(EventArgs e)
{
SubmitButton.Attributes["itemcount"] = Uploader1.Items.Count.ToString();
base.OnPreRender(e);
}
protected void Uploader_FileUploaded(object sender, UploaderEventArgs args) { uploadcount++; InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");
//Copys the uploaded file to a new location.
//args.CopyTo(path);
//You can also open the uploaded file's data stream.
//System.IO.Stream data = args.OpenStream();
}
}