473,480 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

UserControls in a different directory

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.ResolveClie ntUrl(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.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Sep 24 '06 #1
3 1381
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.
--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 24 '06 #2
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.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Gaurav Vaish (www.EduJiniOnline.com)"
<ga*****************@nospam.gmail.comwrote in message
news:uc**************@TK2MSFTNGP02.phx.gbl...
>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.
--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------


Sep 24 '06 #3
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.

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 26 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
994
by: Hendrik W. Hansen | last post by:
I'm working on a WebForm, that through some tabs can load and contain a number of different "plugin" UserControls, all derived from the same "plugin" super class - a bit like the IBuySpy portal. ...
4
1632
by: Anders K. Jacobsen [DK] | last post by:
Hi I have some common UserControls i want to share between to sites (on the same mashine but on diffrent virtual paths). right now i have on solution file with aprox 10 projects. 2 of these is...
1
1166
by: Anders Borum | last post by:
Hello! I was wondering if I am the only person missing the option of outputting a single dll for a website (just like the good old v1.1 compilation model)? What I'm looking for is the ASP.NET...
5
1642
by: David Lozzi | last post by:
Hello, I have an interesting issue, so bear with me as I try to explain. I have a datalist posing as tabs for my application. And as each tab is clicked, a placeholder is then populated with the...
1
1330
by: Jav | last post by:
Using Asp.Net 2.0 I need to acquire rather large amounts of data from the user in my Web App. I have created UserControls to handle different aspects of this data. Placing these UserControls on...
3
891
by: Nathan Sokalski | last post by:
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...
5
2413
by: Nathan Sokalski | last post by:
My Web.config file contains the following section to register some of my UserControls: <pages> <controls> <add tagPrefix="NATE" tagName="Banner" src="~/Banner.ascx"/> <add tagPrefix="NATE"...
7
2115
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
1
1296
by: m.bagattini | last post by:
Hello folks, I'm in trouble with an application using methodologies in subject. The idea is to have a single-page application. The host aspx page coordinates all visualizations, loading and...
0
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.