|
-
Feb 16th, 2012, 01:09 AM
#1
Thread Starter
PowerPoster
[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 ~
-
Feb 16th, 2012, 01:32 AM
#2
Re: Question about paths
try with Page.ResolveUrl(UserProfile.ImageURL)
__________________
Rate the posts that helped you 
-
Feb 16th, 2012, 02:14 AM
#3
Thread Starter
PowerPoster
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.
-
Feb 16th, 2012, 02:30 AM
#4
Thread Starter
PowerPoster
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
-
Feb 16th, 2012, 02:38 AM
#5
Re: Question about paths
something like this:
Code:
<img class="Pic" id="ProfilePic" src='<%# Page.ResolveUrl(DataBinder.Eval(Container.DataItem, "ImageURL"))%>' />
__________________
Rate the posts that helped you 
-
Feb 16th, 2012, 02:56 AM
#6
Thread Starter
PowerPoster
Re: Question about paths
thanks you. works like a charm
-
Feb 16th, 2012, 02:58 AM
#7
Re: [RESOLVED] Question about paths
you are welcome
__________________
Rate the posts that helped you 
-
Feb 22nd, 2012, 11:08 AM
#8
Re: Question about paths
 Originally Posted by Nitesh
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|