Delegates, would those apply here? If so, how? Code examples, as I am new to this area.
Logic separation is what I am intending to implement and I think my task below would be a perfect candidate. I have read that objects should be fairly independent and not hard wired to one another.
ASPX (Page)
<uc1:Attachment ID="Attachment1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
ASPX.cs (Codebehind)
protected void Button1_Click(object sender, EventArgs e)
{
// Check the files and upload
}
ASCX (UserControl)
<MyControl:Upload ID="Upload1" runat="server"
AllowedFileExtensions=".zip,.jpg,.jpeg,.doc,.gif,.png,.txt"
MaxFileInputsCount="3"
OverwriteExistingFiles="false"
onfileexists="Upload1_FileExists"
onvalidatingfile="Upload1_ValidatingFile" />
ASCX.cs (Codebehind)
public Upload AttachmentControl
{
get { return this.Upload1; }
}
The task above is a file upload module. The control that does the upload is in a UserControl which has been dragged on to an ASPX page.
The Submit button on the ASPX page should start the file upload process. This should be a fairly common scenario where the Page saves other information to a database and also upload files.
My instinct from past experience was to expose the Upload control in the UserControl via a public Property. This would tie the Attachment UserControl to the the page.
How can I untie this, perhaps the use of delegates?