Trying to get asp:PlaceHolder to work with NeatUpload

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Trying to get asp:PlaceHolder to work with NeatUpload

Loc Pham
Hi everyone,

Did anyone tried to have a PlaceHolder controller in conjunction with NeatUpload's progress bar?  I kept on getting a NullReference exception and can't figure out the reason.

Here is my code:

Default.aspx
---------------

        <Upload:ProgressBar ID="ProgressBar1" runat='server' Inline="true" Triggers="Button1">
        </Upload:ProgressBar>       
        <Upload:InputFile ID="NU_InputFile1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Upload" />
        <asp:PlaceHolder runat="server" ID="File1ThumbnailPlaceHolder"></asp:PlaceHolder>           
       

Default.aspx.cs:
-----------------

        protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Click += new System.EventHandler(this.UploadBtn1_Clicked);
        }

        protected void UploadBtn1_Clicked(object sender, EventArgs e)
        {
            if (IsValid && NU_InputFile1.HasFile)
            {
                try
                {                    
                    Bitmap img = new Bitmap(NU_InputFile1.FileContent);
                 
                    HttpContext.Current.Session["PrimaryImage"] = img;
                   
                    // Display image from Session variable on previous line.
                    System.Web.UI.WebControls.Image imgTmp = new System.Web.UI.WebControls.Image();
                    imgTmp.ImageUrl = "ImageHandler.ashx?ID=" + 1;
                   
                    File1ThumbnailPlaceHolder.Controls.Clear();
                    File1ThumbnailPlaceHolder.Controls.Add(imgTmp);
                }
                catch(Exception exc){...}
            }
         }

The idea is to try to store the Uploaded image into session variable then resize the image inside the .ashx handler and display the new resized image on the PlaceHolder's ImageUrl.

I placed break points inside the .ashx file and noticed it didn't even execute the .ashx handler file.  However, after File1ThumbnailPlaceHolder.Controls.Add(imgTmp) runs, it threw an exception which the catch statement didn't caught.... The exception then finally caught inside Global.asax.cs Application_Error().

Please advice.  I'm stuck here and can't proceed.
Thanks in advance,
-Loc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to get asp:PlaceHolder to work with NeatUpload

arronlee
Hi, Loc.
Have you ever worked it out? How does the code work? When it comes to the image resizing problem, I have another question for you. I wonder how can I accomplish the image resizing process. Do I need another image resizing SDK to help change the size of images? I am almost a green hand here. Any suggestion will be appreciated. Thanks in advance.    



Best regards,
Arron
--------------------------------------------------------------------------
Tags: resize image
Best Regards,
Arron





Next Tomorrow is Another Day.
Loading...