Results 1 to 8 of 8

Thread: [RESOLVED] Question about paths

  1. #1

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Resolved [RESOLVED] Question about paths

    hi Guys,

    I save the path of where a users profile image is stored in my database
    Code:
    ~/Profile/Images/stig1.jpg
    now in my code behind I create anchor controls dynamically and set the src attribute:

    Code:
    Dim imgStatusImage As HtmlGenericControl = New HtmlGenericControl("img")
                            imgStatusImage.ClientIDMode = UI.ClientIDMode.Static
                            imgStatusImage.ID = String.Format("img{0}", r.Field(Of Integer)("CommentID"))
                            imgStatusImage.Attributes.Add("src", UserProfile.ImageURL)
    I am currently in the directory called Wall/Wall.aspx. Profile is one directory up. If i use ../Profile/Images/stig1.jpg it works. I would have though asp.net would resolve the url when I use the tilde ~. How can I make this work using the ~

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: Question about paths

    try with Page.ResolveUrl(UserProfile.ImageURL)
    __________________
    Rate the posts that helped you

  3. #3

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Question about paths

    thanks riteshjain1982,

    that works I need to do this in page methods as well. Unfortunately I can't use Page.ResolveURL within a page method. Any ideas

    also how can i use it in this aspx markup

    Code:
    <img class="Pic" id="ProfilePic" src='<%(# DataBinder.Eval(Container.DataItem, "ImageURL") %>'>
    Last edited by Nitesh; Feb 16th, 2012 at 02:20 AM.

  4. #4

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Question about paths

    ok for the p[agemethods I did this inside the function:

    Code:
    Dim p As Page = DirectCast(HttpContext.Current.Handler, System.Web.UI.Page)
    I just need to figure out the markup now

  5. #5
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: Question about paths

    something like this:
    Code:
    <img class="Pic" id="ProfilePic"  src='<&#37;# Page.ResolveUrl(DataBinder.Eval(Container.DataItem, "ImageURL"))%>' />
    __________________
    Rate the posts that helped you

  6. #6

    Thread Starter
    PowerPoster Nitesh's Avatar
    Join Date
    Mar 2007
    Location
    Death Valley
    Posts
    2,556

    Re: Question about paths

    thanks you. works like a charm

  7. #7
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [RESOLVED] Question about paths

    you are welcome
    __________________
    Rate the posts that helped you

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Question about paths

    Quote Originally Posted by Nitesh View Post
    thanks you. works like a charm
    The only thing that I would say to this is...

    Why do you need to do this work in the ASPX markup? That is server side code, and you should put it where it belongs. On the server side, IMHO.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width