1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Pluggable Module with Embedded Images

Pluggable Module with Embedded Images

2 posts, 0 answered
  1. Garry
    Garry avatar
    52 posts
    Registered:
    04 Nov 2010
    22 Apr 2009
    Link to this post

    I am trying to figure out how to set image sources in my pluggable module to embedded images.

    I was looking at using the following code, which works in Windows Application environment, but since the ImageUrl requires a string I am lost.

    string nameSpace = "GambitCreations.Sitefinity.WeatherModule.Resources.ccicons";  
                    Assembly myAssembly = Assembly.GetExecutingAssembly();  
                    Stream myStream = myAssembly.GetManifestResourceStream(nameSpace + "MyImage.bmp");  
                     Bitmap bmp = new Bitmap(myStream); 

    My control reference in my module is as such:

    protected virtual Image ccImg  
            {  
                get 
                {  
                    return base.Container.GetControl<Image>("ccImg"true);  
                }  
            } 

    So I was hoping that in the InitializeControls method I could do something like
     
    protected override void InitializeControls(Control controlContainer)  
            {  
                base.InitializeControls(controlContainer);  
     
                if (this.Page != null)  
                {  
                    string nameSpace = "GambitCreations.Sitefinity.WeatherModule.Resources.ccicons.";  
                    ccImg.ImageUrl = nameSpace + 
    ".MyImage.bmp";  
                }  
             } 

    but of course that does not work.

    Anyone have any experience wit this type of scenario?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Apr 2009
    Link to this post
    Hi Garry Clark,

    Instead of the code you have I suggest that you use ClientScriptManager..::.GetWebResourceUrl Method in InitializeControls when you are setting the ImageUrl property.

    Sample:

    this.Page.ClientScript.GetWebResourceUrl(resourcetype, nameofResource) 

    I hope this helps.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered