Skip Navigation Links » Forums » Jiffycms HTML Editor V1.x » Coding-Examples-and-Solutions » Re-Inserting-an-imagepicker-in-the
  • List of posts 
    Inserting an imagepicker in the behindcode
    Inserting an imagepicker in the behindcode
    Not top poster.
    Joined on 25 Oct 2009
    Total posts: 6
    Reply
    Re: Inserting an imagepicker in the behindcode
    Not top poster.
    Joined on 25 Oct 2009
    Total posts: 6
    Reply
    Hello,

    Below is a snippet of the code from page ImageBrowser.aspx from the Demo.

    ---------------------------------------------------------------------------------------
    <cc1:Editor ID="Editor1" runat="server" IconsMode="ImageSprites">
            <EmbeddedImagePicker runat="server"
                ImageBrowserEnabled="true"
                OnImageUploaded="Editor1_EmbeddedImagePicker_ImageUploaded"
                OnBrowseServerRequest="Editor1_EmbeddedImagePicker_BrowseServerRequest">
            </EmbeddedImagePicker>
    </cc1:Editor>
    ----------------------------------------------------------------------------------------

    I am trying to get this working from the behindcode file. I have declared a Editor and a ImagePicker and set the values:

    ----------------------------------------------------------------------------------------
    _contentEditor = new Editor();
    _contentEditor.ID = "contentEditor";
    _contentEditor.IconsMode = IconType.Icons;     

    _imagePicker = new ImagePicker();
    _imagePicker.ID = "imagePicker";
    _imagePicker.ImageBrowserEnabled = true;
    _imagePicker.ImageUploaded += new UploadedImageFileEventHandler(_imagePicker_ImageUploaded);
    _imagePicker.BrowseServerRequest += new EventHandler(_imagePicker_BrowseServerRequest);
    ----------------------------------------------------------------------------------------

    But I can't find the option to add the ImagePicker to the Editor. I tryed the following, but that is read only...

    ----------------------------------------------------------------------------------------
    _contentEditor.EmbeddedImagePicker = _imagePicker;
    ----------------------------------------------------------------------------------------

    I hope it is clear what I want to do. I just want to create the code from ImageBrowser.aspx in the behindcode file, but adding the ImagePicker to the Editor isn't working.

    Thanks in advance

    Cees van Altena.
    Re: Inserting an imagepicker in the behindcode
    Forum moderator
    Not top poster.
    Joined on 06 Jan 2009
    Total posts: 210
    Reply

    hello Cees,

    You must use the EmbeddedImagePicker property itself in code. What you see in declarative code is the same property serialized to an xml representation and ineffect it looks more like we are manually embedding an image picker.

    To translate what you are trying to achieve in code, this is how you would go about it :

    C#

    protected void Page_Init(object sender, EventArgs e)
    {
    Editor1.EmbeddedImagePicker.ImageBrowserEnabled = true;
    Editor1.EmbeddedImagePicker.ImageUploaded +=
    new UploadedImageFileEventHandler(EmbeddedImagePicker_ImageUploaded);
    Editor1.EmbeddedImagePicker.BrowseServerRequest +=
    new EventHandler(EmbeddedImagePicker_BrowseServerRequest);
    }

    void EmbeddedImagePicker_BrowseServerRequest(object sender, EventArgs e)
    {
    //populate the nodes
    }

    void EmbeddedImagePicker_ImageUploaded(object sender, UploadedImageFileEventArgs e)
    {
    //do something with uploaded image
    }

    Somethings to note is how I don't create a new instance of an imagepicker but rather use the instance exposed by the editor itself. Let me know if something is not clear.

    Have a good day,



    Alessandro Zifiglio
    Jiffycms.net
    We are now on twitter! Follow us for the latest.