locked
Embedding images in custom server control RRS feed

  • Question

  • User151722123 posted

    Hi Everybody , i am making a custom server control. I have embedded images and javascript in class library.

    But images are not displaying when i use that control in aspx page.

    my code is

    [assembly: WebResource("ClassLibrary1.mail2mohanpyare.skins.kama.icons.png", "img/png")]

    and how can i convert ckeditor in class library.

    Plz help, It's urgent.

    Friday, January 8, 2010 3:46 AM

All replies

  • User1282917655 posted

    make sure that the "Build Action" property for the image is set to "Embedded Resource" 

    Friday, January 8, 2010 6:26 AM
  • User151722123 posted

    Thanks buddy But i have already done this.

    Please Help

    Friday, January 8, 2010 7:41 AM
  • User1282917655 posted

    send your code, your assembly name (project), and the code where you are rendering the image

    Friday, January 8, 2010 8:08 AM
  • User-16411453 posted

    It must be in the class code, in vb it's

    Dim cs As ClientScriptManager = Me.Page.ClientScript
            Dim rsType As Type = Me.GetType()


    'Register the javascript
            If (Not cs.IsClientScriptIncludeRegistered(rsType, "ItemIndex")) Then
                cs.RegisterClientScriptInclude("ItemIndex", cs.GetWebResourceUrl(rsType, "redCopper.ice5.admin_management.ItemIndex.js"))
            End If


    Dim TheImageURL As String = cs.GetWebResourceUrl(rsType, "redCopper.ice5.admin_management.loading_animation_liferay.gif")


    Sunday, January 10, 2010 12:57 AM
  • User151722123 posted

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Web.UI;
    using System.Drawing;
    using System.Web.UI.WebControls;

    namespace Test
    {
        public class Test : System.Web.UI.WebControls.WebControl, INamingContainer
        {
            System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
            public override ControlCollection Controls
            {
                get
                {
                    EnsureChildControls();
                    return base.Controls;
                }
            }
            protected override void CreateChildControls()
            {
                Controls.Clear();
                img.ImageUrl = "/makeup.jpg";
                img.Width = 500;
                img.Height = 500;
                img.BorderWidth = 5;
                img.BorderColor = System.Drawing.Color.Red;
                // Set subcontrols behavior
               
                Controls.Add(img);
            }
        }
    }


    using System.Reflection;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Web.UI;
    // General Information about an assembly is controlled through the following
    // set of attributes. Change these attribute values to modify the information
    // associated with an assembly.
    [assembly: AssemblyTitle("Test")]
    [assembly: AssemblyDescription("")]
    [assembly: AssemblyConfiguration("")]
    [assembly: AssemblyCompany("")]
    [assembly: AssemblyProduct("Test")]
    [assembly: AssemblyCopyright("Copyright ©  2010")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]
    // Setting ComVisible to false makes the types in this assembly not visible
    // to COM components.  If you need to access a type in this assembly from
    // COM, set the ComVisible attribute to true on that type.
    [assembly: ComVisible(false)]


    [assembly: WebResource ("Test.makeup.jpg","img/jpg")]


    // The following GUID is for the ID of the typelib if this project is exposed to COM
    [assembly: Guid("b7a7ab44-7327-472c-a326-055f533a6210")]

    // Version information for an assembly consists of the following four values:
    //
    //      Major Version
    //      Minor Version
    //      Build Number
    //      Revision
    //
    // You can specify all the values or you can default the Build and Revision Numbers
    // by using the '*' as shown below:
    // [assembly: AssemblyVersion("1.0.*")]
    [assembly: AssemblyVersion("1.0.0.0")]
    [assembly: AssemblyFileVersion("1.0.0.0")]


    I want when i add this control to my .aspx page, image should be displayed. I am just testing this. I have to make a class library of this type.

    any suggestion will be appreciated.

    Monday, January 11, 2010 4:06 AM
  • User-16411453 posted

    You need to put a client script editor on the page, to call an embedded object from within the dll

    That's what the cs is, and the rs

    That would go in your createchildcontrol


    Monday, January 11, 2010 7:12 PM
  • User151722123 posted

    Thanks Dear, I simply want to make a editor like ajax editor, everything is embedded in .dll file. When control is added to .aspx page, all images like bold, italic, and othere are displayed without putting these files separately in project.

    Thanks

    Tuesday, January 12, 2010 1:11 AM
  • User151722123 posted

    Thanks Dear, I simply want to make a editor like ajax editor, everything is embedded in .dll file. When control is added to .aspx page, all images like bold, italic, and othere are displayed without putting these files separately in project.

    Thanks

    Tuesday, January 12, 2010 1:19 AM
  • User-16411453 posted

    You misread my comment. The editor I mentioned is an asp.net object called client script manager.

    The client script manager manages client scripts, in which it works with embedded content.

    Tuesday, January 12, 2010 5:36 PM
  • User151722123 posted

    Dear Thank Again.

    I am not getting how to implement this. I just want to add functionality like ajax editor, control is added to the aspx page and done. We don't put anycode in our project to display images from ajax toolkit dll. what to do to implement this.  How everything that is merged in ajaxtoolkit class library(like images) and when control is added , images are displayed on the page.

    Plz it's urgent.

    Wednesday, January 13, 2010 7:25 AM