November Happy Hour will be moved to Thursday December 5th.

Rendering Image in user control in epi server cms 7.5

Vote:
 

how can i render image in user control tell me guys urgent i need

#120767
Apr 24, 2015 7:01
Vote:
 

You render images just like in any aspx page. Not sure what you are after but you can have a specific user control hook on all images if you like that as well by adding a user control whit a backend looking something like this:

TemplateDescriptor(Inherited = true)]
public partial class ImageControl : ContentControlBase<imagedata>
{
    protected Injected<urlresolver> UrlResolver { get; set; }
 
    protected string ImageUrl
    {
        get
        {
            return UrlResolver.Service.GetUrl(CurrentData.ContentLink);
        }
    }
}
#120770
Apr 24, 2015 8:06
Vote:
 

YA BUT I WANT RENDER CODE BEHIND

using EPiServer;
using EPiServer.Core;
using EPiServer.Web.Mvc.Html;
using EPiServer.Web.WebControls;
using EpiserverCMS8.Models.Pages;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EpiserverCMS8.Models;


namespace EpiserverCMS8.Views.UserControls
{
public partial class MainMenu : UserControlBase<DefaultTemplate>
{
public string strSelectedPage = string.Empty;
public string siteHeading = string.Empty;
public string QueryString = string.Empty;
protected override void OnLoad(System.EventArgs e)
{
base.OnLoad(e);
PageReference pg = PageReference.StartPage as PageReference;
PageData pd = GetPage(pg);
siteHeading = Convert.ToString(pd.Property["SiteHeading"]);
//PageReference pdg = CurrentPage.PageLink as PageReference;
logopc.ImageUrl = Convert.ToString(pd.Property["Logotype"]);
//logopc.ImageUrl = UrlExtensions.(pd.Property["LogoType"]) ?? string.Empty;

logopc.NavigateUrl = "/en/";
logomobile.ImageUrl = Convert.ToString(pd.Property["Logotype_mob"]);
logomobile.NavigateUrl = "/en/";
QueryString = "";

Menu.PageLink = PageReference.StartPage;
Menu.PageLoader.GetChildrenCallback = new HierarchicalPageLoader.GetChildrenMethod(LoadChildren);
Menu.DataBind();
}

private PageDataCollection LoadChildren(PageReference pageLink)
{
PageDataCollection pages = DataFactory.Instance.GetChildren(pageLink);
// int no = pages.IndexOf("Library");
int PagesCount = pages.Count;
PagesCount = PagesCount - 8;
//pages.RemoveRange(6, PagesCount);
// pages.Insert(0, DataFactory.Instance.GetPage(pageLink));
return pages;
}


}
}

ABOUE BOLD TAG IMAGE CODE NOT WORKING

#120779
Apr 24, 2015 9:32
Vote:
 

Suresh. If you want answer to your question you have to start to be more gentle and not screaming (writing with capital letters is to scream).

You have the answer in your other thread:

http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=120648&epslanguage=en

#120780
Apr 24, 2015 9:45
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.