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
  1. Home
  2. Web Development
  3. SharePoint
  4. How to add images and refer to them from a web part in SharePoint 2007

How to add images and refer to them from a web part in SharePoint 2007

Scheduled Pinned Locked Moved SharePoint
sysadminphpcsssharepointcom
9 Posts 3 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.
  • R Offline
    R Offline
    Rocky
    wrote on last edited by
    #1

    hi there, I need to know how you can add images in a web part and contain them inside the web part so that when you deploy it on another server, the images automatically go with the whole package and get mapped automatically also. It was pretty easy with SP2010 as it has the “Mapped Folder” thing in it. So far I see a pictures library to use but you’d have to do something special for deployment purposes as I understand it. What I’m doing right now is that I am developing a web part with a grid view which would have standard icon like images in a column. What’s the best way to manage these images is what I’m looking for? Thank you very much for your help in advance! :rose:

    Rocky My Blog

    N 1 Reply Last reply
    0
    • R Rocky

      hi there, I need to know how you can add images in a web part and contain them inside the web part so that when you deploy it on another server, the images automatically go with the whole package and get mapped automatically also. It was pretty easy with SP2010 as it has the “Mapped Folder” thing in it. So far I see a pictures library to use but you’d have to do something special for deployment purposes as I understand it. What I’m doing right now is that I am developing a web part with a grid view which would have standard icon like images in a column. What’s the best way to manage these images is what I’m looking for? Thank you very much for your help in advance! :rose:

      Rocky My Blog

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Rocky# wrote:

      you’d have to do something special for deployment purposes

      No, nothing special needs to be done for development vs production. As with any .net application you can use embedded resources, which is a techniques often used by third parties when developing webparts. http://blogs.msdn.com/b/ryanrogers/archive/2006/05/01/588166.aspx[^] You can also always deploy the images to the layouts folder as with any standard SharePoint application and reference them from that location in your webpart.


      No comment

      M R 2 Replies Last reply
      0
      • N Not Active

        Rocky# wrote:

        you’d have to do something special for deployment purposes

        No, nothing special needs to be done for development vs production. As with any .net application you can use embedded resources, which is a techniques often used by third parties when developing webparts. http://blogs.msdn.com/b/ryanrogers/archive/2006/05/01/588166.aspx[^] You can also always deploy the images to the layouts folder as with any standard SharePoint application and reference them from that location in your webpart.


        No comment

        M Offline
        M Offline
        Manoj_Leo
        wrote on last edited by
        #3

        add a Image mapped folder in your VS solution. Add all you images there and deploy the solution ..follow the below mentioned article from MSDN http://blogs.msdn.com/b/vssharepointtoolsblog/archive/2010/03/12/deploying-files-using-mapped-folders.aspx

        R 1 Reply Last reply
        0
        • N Not Active

          Rocky# wrote:

          you’d have to do something special for deployment purposes

          No, nothing special needs to be done for development vs production. As with any .net application you can use embedded resources, which is a techniques often used by third parties when developing webparts. http://blogs.msdn.com/b/ryanrogers/archive/2006/05/01/588166.aspx[^] You can also always deploy the images to the layouts folder as with any standard SharePoint application and reference them from that location in your webpart.


          No comment

          R Offline
          R Offline
          Rocky
          wrote on last edited by
          #4

          Thanks for the comment Mark, I'm trying to use the embedded resources method so what I've done is I added resource file to the web part project, then I added the two pictures as resources and tried to get the URL of those by doing something like

          img.ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(Image), "ActivityActualSignedLarge.png");

          I have also tried doing it like

          My.Namespace.Name.Resources.Imagename.png

          where Resources is the name of the resource file but it doesn't show the image as well. While debugging I do see a relative path but that is generated even if I input a non existent name of the image as well. So... what am I doing wrong now :( Appreciate your help!

          Rocky My Blog

          N 1 Reply Last reply
          0
          • M Manoj_Leo

            add a Image mapped folder in your VS solution. Add all you images there and deploy the solution ..follow the below mentioned article from MSDN http://blogs.msdn.com/b/vssharepointtoolsblog/archive/2010/03/12/deploying-files-using-mapped-folders.aspx

            R Offline
            R Offline
            Rocky
            wrote on last edited by
            #5

            No I think you got it wrong because this article deals with SP 2010. I'm working in SP07. But thanks a lot anyway :)

            Rocky My Blog

            M 1 Reply Last reply
            0
            • R Rocky

              No I think you got it wrong because this article deals with SP 2010. I'm working in SP07. But thanks a lot anyway :)

              Rocky My Blog

              M Offline
              M Offline
              Manoj_Leo
              wrote on last edited by
              #6

              Hi It depends on the which visual Studio you are using VS2010 provides this option for SP2007 also the only difference is .. in case of SP2007 it use to map "12" hive "images" folder and for SP2010 it use to Map "14" hive "images" folder. Cheers :)

              R N 2 Replies Last reply
              0
              • M Manoj_Leo

                Hi It depends on the which visual Studio you are using VS2010 provides this option for SP2007 also the only difference is .. in case of SP2007 it use to map "12" hive "images" folder and for SP2010 it use to Map "14" hive "images" folder. Cheers :)

                R Offline
                R Offline
                Rocky
                wrote on last edited by
                #7

                hi, I didnt know that till now. Could you please elaborate on that a bit more coz I'm working in VS2010. When I right click the solution file (or the project file too) and go to Add then I dont see any option of Adding a mapped folder or something similar. Actually I have developed a few web parts in SP2010 so I was familiar with this option as well but can't find this with SP2007. Thanks,

                Rocky My Blog

                1 Reply Last reply
                0
                • M Manoj_Leo

                  Hi It depends on the which visual Studio you are using VS2010 provides this option for SP2007 also the only difference is .. in case of SP2007 it use to map "12" hive "images" folder and for SP2010 it use to Map "14" hive "images" folder. Cheers :)

                  N Offline
                  N Offline
                  Not Active
                  wrote on last edited by
                  #8

                  I believe you are mistaken. With Visual Studio 2010 there is no option for creating a SP2007 solutions, only workflows. Also, the more correct, IMO, way to accomplish the task is to bundle the images as resources that are distributed in the assembly.


                  No comment

                  1 Reply Last reply
                  0
                  • R Rocky

                    Thanks for the comment Mark, I'm trying to use the embedded resources method so what I've done is I added resource file to the web part project, then I added the two pictures as resources and tried to get the URL of those by doing something like

                    img.ImageUrl = Page.ClientScript.GetWebResourceUrl(typeof(Image), "ActivityActualSignedLarge.png");

                    I have also tried doing it like

                    My.Namespace.Name.Resources.Imagename.png

                    where Resources is the name of the resource file but it doesn't show the image as well. While debugging I do see a relative path but that is generated even if I input a non existent name of the image as well. So... what am I doing wrong now :( Appreciate your help!

                    Rocky My Blog

                    N Offline
                    N Offline
                    Not Active
                    wrote on last edited by
                    #9

                    Without seeing what you are actually doing there isn't much advice I can offer except make sure you have gone through the article completed and followed all of the steps. Another resource that may here is here http://support.microsoft.com/kb/910442[^]. Otherwise, there is a great deal of documentation out there for this technique, it is not specific to SharePoint, it is ASP.NET


                    No comment

                    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