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. ASP.NET
  4. How to show a default photo.

How to show a default photo.

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
11 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.
  • W Offline
    W Offline
    www Developerof NET
    wrote on last edited by
    #1

    Hi all, I want to display employee photo whenever he logs in. I am not storing the url of photo in database instead i have created a folder in which the photo is saved with empid name.I want that if the photo doesn`t exist a default pic to be shown.If the photo exists in the folder,the pic be shown. how do i achieve this. Thankx in advance.

    _ D 3 Replies Last reply
    0
    • W www Developerof NET

      Hi all, I want to display employee photo whenever he logs in. I am not storing the url of photo in database instead i have created a folder in which the photo is saved with empid name.I want that if the photo doesn`t exist a default pic to be shown.If the photo exists in the folder,the pic be shown. how do i achieve this. Thankx in advance.

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      So what exactly is the problem you are having? What you need to do is to find the reuired image in the folder and if not found display the default image.

      Best Regards, Apurva Kaushal

      1 Reply Last reply
      0
      • W www Developerof NET

        Hi all, I want to display employee photo whenever he logs in. I am not storing the url of photo in database instead i have created a folder in which the photo is saved with empid name.I want that if the photo doesn`t exist a default pic to be shown.If the photo exists in the folder,the pic be shown. how do i achieve this. Thankx in advance.

        D Offline
        D Offline
        dinus28
        wrote on last edited by
        #3

        hi let us say u have an image object. it has a property imageurl which u can set at runtime. since u r knowing the empid of the user logging in its easy for u to trace the imagename from the source directory. the only thing u have to check whether the image exists r not. try this and see. if it has any prob let me know for further asst.

        W 1 Reply Last reply
        0
        • D dinus28

          hi let us say u have an image object. it has a property imageurl which u can set at runtime. since u r knowing the empid of the user logging in its easy for u to trace the imagename from the source directory. the only thing u have to check whether the image exists r not. try this and see. if it has any prob let me know for further asst.

          W Offline
          W Offline
          www Developerof NET
          wrote on last edited by
          #4

          Where`s the code??? I just want to check whether the photo exists or not.What happens is i set the URL as IMG1.Src="c:\\"+empid+".jpg" .But if the photo is not present it displays nothing(it`s obvious).What to do???

          _ D 2 Replies Last reply
          0
          • W www Developerof NET

            Where`s the code??? I just want to check whether the photo exists or not.What happens is i set the URL as IMG1.Src="c:\\"+empid+".jpg" .But if the photo is not present it displays nothing(it`s obvious).What to do???

            _ Offline
            _ Offline
            _AK_
            wrote on last edited by
            #5

            Prior to set the src to the image you need to search for the image. This you can do with simple file handling objects.

            Best Regards, Apurva Kaushal

            W 1 Reply Last reply
            0
            • _ _AK_

              Prior to set the src to the image you need to search for the image. This you can do with simple file handling objects.

              Best Regards, Apurva Kaushal

              W Offline
              W Offline
              www Developerof NET
              wrote on last edited by
              #6

              Sorry,but i have no knowledge of handling files. Can u give me the code .. Please..

              _ 1 Reply Last reply
              0
              • W www Developerof NET

                Sorry,but i have no knowledge of handling files. Can u give me the code .. Please..

                _ Offline
                _ Offline
                _AK_
                wrote on last edited by
                #7

                You can use System.IO.File.Exists("path") to check whether file exists or not.

                Best Regards, Apurva Kaushal

                W 1 Reply Last reply
                0
                • W www Developerof NET

                  Where`s the code??? I just want to check whether the photo exists or not.What happens is i set the URL as IMG1.Src="c:\\"+empid+".jpg" .But if the photo is not present it displays nothing(it`s obvious).What to do???

                  D Offline
                  D Offline
                  dinus28
                  wrote on last edited by
                  #8

                  hi iam sorry. i didnot know that u wanted the code.anyways did u get it r not.

                  1 Reply Last reply
                  0
                  • W www Developerof NET

                    Hi all, I want to display employee photo whenever he logs in. I am not storing the url of photo in database instead i have created a folder in which the photo is saved with empid name.I want that if the photo doesn`t exist a default pic to be shown.If the photo exists in the folder,the pic be shown. how do i achieve this. Thankx in advance.

                    D Offline
                    D Offline
                    dinus28
                    wrote on last edited by
                    #9

                    i have pasted a sample code. here label1.text stands for ur empid iam using a image server control i created a folder in the app path named photo where i stored my sample pics this is how i accessed and set the object. i hope u can modify further acc to ur reqts. Dim s As String = CurDir() Dim s1 As String = s & "\Photo" Dim s2() As String Dim s3 As String Dim i As Integer Dim j As Integer Label1.Text = "yasoda2" If Directory.Exists(s1) Then s2 = Directory.GetFiles(s1) For i = 0 To s2.Length() - 1 j = s2(i).IndexOf(".") s3 = Left(s2(i), j) If (s3 = s1 & "\" & Label1.Text) Then Image1.ImageUrl = s2(i).Replace(s, "~") End If Next Else Console.Write("Directory dose not exist") End If

                    1 Reply Last reply
                    0
                    • _ _AK_

                      You can use System.IO.File.Exists("path") to check whether file exists or not.

                      Best Regards, Apurva Kaushal

                      W Offline
                      W Offline
                      www Developerof NET
                      wrote on last edited by
                      #10

                      Thanks it`s working!!!

                      _ 1 Reply Last reply
                      0
                      • W www Developerof NET

                        Thanks it`s working!!!

                        _ Offline
                        _ Offline
                        _AK_
                        wrote on last edited by
                        #11

                        Always welcome.. :)

                        Best Regards, Apurva Kaushal

                        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