More in this section
Forums / Developing with Sitefinity / Uploading Pictures during Edit

Uploading Pictures during Edit

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Joey
    Joey avatar
    2 posts
    19 Aug 2012
    10 Dec 2010
    Link to this post

    I've worked at this for several days and searched for a solution, found several portions and built them all but I still can't figure this simple thing out.

    I have an Ajaxified Grid (EnabledAjax="True") in which I have GridTemplateColumn which contains an asp:Image tags to display a thumbnail of the image.  The image resides in the filesystem.  Works great.

    In the EditFormSettings, because I have so many fields, I organize them into RadTabStrip and a RadMultiPage.  On the Photos tab, I display the three pictures (Thumbnail, Small and Large Image) in a div along with a RadUpload.  I can get the picture to display, my textbox containing the relative path to the image.  Works good.

    The problem comes during the upload, I select a picture and press the Upload button.  Good so far!  I catch the server side postback Click event, find the control for the image, get the parent, then set the correct imageURL, the correct relative datapath.  All seems to work, but (and here's the problem) it won't change the EditFormSettings page to reflect the changes which should then post to the database or reflect the changes and allow me to press the Update button.  It just closes the form and every change is lost and the EditForm closes losing the changes.

    Here is my click event:

    protected void ButtonUploadThumbnailImage_Click(object sender, EventArgs e)
            Button btn = (Button)sender;
            GridEditFormItem editFormItem = (GridEditFormItem)btn.NamingContainer;  //Access the EditFormItem
            RadUpload upload = (RadUpload)editFormItem.FindControl("UploadThumbnailImage");

            if (upload.UploadedFiles.Count > 0)
                Image image = (Image)editFormItem.FindControl("ThumbnailImage");
                image.ImageUrl = ResolveUrl("~/Images/Products/" + upload.UploadedFiles[0].GetName());

                TextBox txt1 = (TextBox)editFormItem.FindControl("txtThumbnailImagePath");
                txt1.Text = "~/Images/Products/" + upload.UploadedFiles[0].GetName();

    My html example is:

    <td valign="top" 
    <telerik:RadUpload ID="UploadThumbnailImage" runat="server" Width="250px" 
    AllowedFileExtensions="jpg,jpeg,png,gif" ControlObjectsVisibility="None" 
    <asp:Button ID="ButtomUploadThumbnailImage" runat="server" Text="Upload" 
    OnClick="ButtonUploadThumbnailImage_Click" /><br 
    <asp:Image ID="ThumbnailImage" runat="server" ImageUrl='<%# ResolveUrl("~" 
    + Eval("ThumbnailImageURL")) 
    Visible='<%# Eval("ThumbnailImageURL").Equals("") ? false: true %>' 
    <asp:TextBox ID="txtThumbnailImagePath" runat="server" Text='<%# 

    How do I display an image using a relative path from the database, allow the user to upload and change the picture (or select one already uploaded) and then reflect the change in the EditForm but not save it to the database until the EditFormSettings Update button is pressed?


1 posts, 0 answered