Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Nathan Sokalski #1
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
[email]njsokalski@hotmail.com[/email]
[url]http://www.nathansokalski.com/[/url]
Nathan Sokalski Guest
-
UserControls ASP.NET 2.0
Hi All, What is the best way to develop and use UserControls on an ASPX page with the new dynamic compilation model introduced in ASP.NET 2.0? ... -
Abstract Usercontrols
We have some questions about 'abstract' and 'usercontrol'. A project that we are working on has user controls that are marked as abstract. 1. ... -
Recursive UserControls? Are they possible?
I am trying to implement something similar to a treeview in an asp.net usercontrol. As this control has no need to allow multiple branches to be... -
UserControls in datagrid
Vincent Destombes wrote: Do you rebind your datagrid on postback? If you don't, the itemcreated event will not be called on postback, and your... -
Using UserControls in a DLL
You need to create a refrence to the usercontrol project (assuming you created this in vs.net) in your current projects refrences. Alternatively,... -
Gaurav Vaish \(www.EduJiniOnline.com\) #2
Re: UserControls in a different directory
> In the Page that uses this UserControl I pass it the value
> "images/bannerad.jpg". However, when I open the page, the Response.Write()Probably because your page is within a folder 'usercontrols' related to the> gets assigned to lnkAdvertisement.ImageUrl is
> 'usercontrols/images/bannerad.jpg'. Why is a different value being
> returned
application-root.
Prefer using the form "~/images/bannerad.jpg" instead.
--
Happy Hacking,
Gaurav Vaish | [url]http://www.mastergaurav.com[/url]
[url]http://www.edujinionline.com[/url]
[url]http://articles.edujinionline.com/webservices[/url]
-------------------
Gaurav Vaish \(www.EduJiniOnline.com\) Guest
-
Nathan Sokalski #3
Re: UserControls in a different directory
Is there a way to get the directory that the Page using the control is in?
For example, if my Page was located at
[url]http://localhost/home/extrapages/misc/mypage.aspx[/url]
it would return
[url]http://localhost/home/extrapages/misc/[/url]
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
[email]njsokalski@hotmail.com[/email]
[url]http://www.nathansokalski.com/[/url]
"Gaurav Vaish (www.EduJiniOnline.com)"
<gaurav.vaish.nospam@nospam.gmail.com> wrote in message
news:ucDYAk73GHA.2420@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 | [url]http://www.mastergaurav.com[/url]
> [url]http://www.edujinionline.com[/url]
> [url]http://articles.edujinionline.com/webservices[/url]
> -------------------
>
>
Nathan Sokalski Guest
-
Gaurav Vaish \(www.EduJiniOnline.com\) #4
Re: UserControls in a different directory
> [url]http://localhost/home/extrapages/misc/mypage.aspx[/url]
look at: HttpRequest::Url, HttpRequest::PathInfo and HttpRequest::Path>
> it would return
>
> [url]http://localhost/home/extrapages/misc/[/url]
You can obtain instance of HttpRequest from the Request property of the
page.
--
Happy Hacking,
Gaurav Vaish | [url]http://www.mastergaurav.com[/url]
[url]http://www.edujinionline.com[/url]
[url]http://articles.edujinionline.com/webservices[/url]
-------------------
Gaurav Vaish \(www.EduJiniOnline.com\) Guest



Reply With Quote

