Okay I was able to add files into the AttachmentItem not from database but from simple string which I can change later after testing this.
This is what I have;
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
- SampleUtil.SetPageCache();
-
- string str = Server.MapPath("uploaded/img1.jpg");
- System.Net.WebRequest req = System.Net.WebRequest.Create(str);
- Stream streamImg = req.GetResponse().GetResponseStream();
-
- Response.Write(streamImg.ToString());
-
- Attachments1.Items.Add(192, "img1Filename", streamImg);
- Attachments1.AttachmentAdded += new AttachmentItemEventHandler(Attachments1_AttachmentAdded);
- ButtonDeleteAll.Click += new EventHandler(ButtonDeleteAll_Click);
- ButtonTellme.Click += new EventHandler(ButtonTellme_Click);
- }
Now when the page loads I have 1 item which I added using the code above, the problem is whenever I try to delete it I get an error that says;
Error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'System.Net.FileWebSt'.
Any idea what this is? I think Im using the Attachment1.Items.Add and the Stream wrong.
- Ryan