Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / September 2006

Tip: Looking for answers? Try searching our database.

UserControls in a different directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 24 Sep 2006 08:03 GMT
I have my UserControls in a subdirectory called usercontrols. In the code
for one of my UserControls I have the following:

   Public Property adimage() As String
       Get
           Return lnkAdvertisement.ImageUrl
       End Get
       Set(ByVal value As String)
           Response.Write(Me.Page.ResolveClientUrl(value) & "<br/>" &
ControlChars.NewLine)
           lnkAdvertisement.ImageUrl = Me.Page.ResolveClientUrl(value)
           System.Diagnostics.Debug.Write(Me.Page.ResolveClientUrl(value))
       End Set
   End Property

In the Page that uses this UserControl I pass it the value
"images/bannerad.jpg". However, when I open the page, the Response.Write()
and Debug.Write() lines both output 'images/bannerad.jpg' but the value that
gets assigned to lnkAdvertisement.ImageUrl is
'usercontrols/images/bannerad.jpg'. Why is a different value being returned
by Me.Page.ResolveClientUrl(value)? My main goal is to make the paths I pass
when using the UserControl to be treated as relative to the path of the Page
containing the UserControl, not the path of the UserControl. What should I
do? Thanks.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Gaurav Vaish (www.EduJiniOnline.com) - 24 Sep 2006 10:07 GMT
> In the Page that uses this UserControl I pass it the value
> "images/bannerad.jpg". However, when I open the page, the Response.Write()

> gets assigned to lnkAdvertisement.ImageUrl is
> 'usercontrols/images/bannerad.jpg'. Why is a different value being
> returned

Probably because your page is within a folder 'usercontrols' related to the
application-root.
Prefer using the form "~/images/bannerad.jpg" instead.

Signature

Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------

Nathan Sokalski - 24 Sep 2006 20:26 GMT
Is there a way to get the directory that the Page using the control is in?
For example, if my Page was located at

http://localhost/home/extrapages/misc/mypage.aspx

it would return

http://localhost/home/extrapages/misc/

I need to be able to enter URLs relative to a page regardless of what
directory the page is in, and throwing the ~/ in front of the relative
directory only works if the page is located in the application root. Any
ideas? Thanks.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

>> In the Page that uses this UserControl I pass it the value
>> "images/bannerad.jpg". However, when I open the page, the
[quoted text clipped - 7 lines]
> the application-root.
> Prefer using the form "~/images/bannerad.jpg" instead.
Gaurav Vaish (www.EduJiniOnline.com) - 26 Sep 2006 18:55 GMT
> http://localhost/home/extrapages/misc/mypage.aspx
>
> it would return
>
> http://localhost/home/extrapages/misc/

look at: HttpRequest::Url, HttpRequest::PathInfo and HttpRequest::Path
You can obtain instance of HttpRequest from the Request property of the
page.

Signature

Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.