RE: How to use -- Attachments1.Items.Add

  •  08-14-2009, 8:23 PM

    RE: How to use -- Attachments1.Items.Add

    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;
     
    1. protected override void OnInit(EventArgs e)  
    2. {  
    3.     base.OnInit(e);  
    4.     SampleUtil.SetPageCache();  
    5.       
    6.     string str = Server.MapPath("uploaded/img1.jpg");  
    7.     System.Net.WebRequest req = System.Net.WebRequest.Create(str);  
    8.     Stream streamImg = req.GetResponse().GetResponseStream();  
    9.   
    10.     Response.Write(streamImg.ToString());  
    11.   
    12.     Attachments1.Items.Add(192, "img1Filename", streamImg);  
    13.     Attachments1.AttachmentAdded += new AttachmentItemEventHandler(Attachments1_AttachmentAdded);  
    14.     ButtonDeleteAll.Click += new EventHandler(ButtonDeleteAll_Click);  
    15.     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
View Complete Thread