More in this section

Forums / Developing with Sitefinity / General ImageField Question: Where to go from here

General ImageField Question: Where to go from here

2 posts, 0 answered
  1. Chris
    Chris avatar
    12 posts
    10 Aug 2010
    17 May 2012
    Link to this post
    Hi. I am pretty new to developing in Sitefinity and I have some very elementary questions about the ImageField control. I have created a user control that I added to a Backend page. Basically I would like to use the ImageField control for selecting and uploading images. The control displays properly and I can select images that are on the server. When I click my
     form submit button I would like to simply take the input and store it into a table that I have created. Pretty standard stuff. I am having trouble figuring out how to retrieve the URL of the image from the ImageField control during the post back. I figured it would be something like

    String ImageURL = ImageSelector.Value.ToString();

    However this returns an empty string. I have set the DataFieldType to String.

    Here is my user control code behind:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    namespace SitefinityWebApp.Modules.Carousels.Admin
        public partial class CarouselCreateAdmin : System.Web.UI.UserControl
            protected void Page_Load(object sender, EventArgs e)
                // set the image selector type to use string (src)
                ImageSelector.DataFieldType = typeof(String);
                    Response.Write("Image URL: " + ImageSelector.Value);

    and here is my .ascx code:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CarouselCreateAdmin.ascx.cs" Inherits="SitefinityWebApp.Modules.Carousels.Admin.CarouselCreateAdmin" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.Fields" TagPrefix="sf" %>
    <div id="control-wrapper">
        <div class="text-wrap">
            <label class="sfTxtLbl">Select An Image:</label>
            <sf:ImageField ID="ImageSelector" runat="server" DisplayMode="Write" UploadMode="Dialog" DataFieldName="Image" />

    I am developing for Sitefinity 4.4. I'm sure this is very basic but I am having trouble and have yet to find the answer in the forums. Any assistance would be most helpful. Thanks in advance.
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    18 Jul 2012
    17 May 2012
    Link to this post
    the imagefield uses javascript to persist the data back to your widget property, and must do so through a control designer.

    for a walkthrough using the imagefield in a control designer, take a look at this post, which also has a downloadable example project: Selecting Sitefinity 4 Content Inside Widget Designers

    for more information about control designers take a look at this post: “Hello World” guide to custom Sitefinity Widgets & ControlDesigners

    hope this is helpful!
2 posts, 0 answered