Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom Control with Images

Custom Control with Images

Scheduled Pinned Locked Moved ASP.NET
questionhelpcsharpvisual-studiodesign
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christopher Stratmann
    wrote on last edited by
    #1

    What is the best way to do this? I am making a custom control (not a user control) which shows an image to the user through a web page. How do I get the image from the custom control into my web page images directory? Right now I have the custom control in a class library project. I have the image stored within the Resources.resx file in the class library. The custom control has a property where the programmer enters in the image directory location (a relative location) of the web site. The custom controls protected override void RenderContents(HtmlTextWriter writer) function goes into the given image directory location with the help of Page.MapPath() and checks to see if the image exists and if it doesn't exist then the image is copied from the Properties.Resources.MyImage to that location. Problems that I am having with the above method: 1. It does seem very efficient to check to see if the image file exists every time the custom control is rendered. 2. At design time (within visual studio 2005), when I place the control on a web page and set the image directory location the image doesn't show up. Instead, I get some weird error message. But when I run the web page the image shows up fine. Is there a better way of doing this? Chris

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups