473,624 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Path in a control in a master page does not work!

I can use a good help here with what looks like a simple problem.

I have a control called Header.ascx in /Control/System directory, where / is
my web application directory.

The header is used in a master page called MasterPage.mast er in the /
directory.

I have a Default.aspx in / which uses the master page in the root. The user
control (which is really in the master page) in this page shows fine.

The problem is /directory1/earthquake.aspx . This page also uses the master
page in the / directory.

When this page is displayed, the control does not show like the Default.aspx
in the / directory.

So, I tried changing <img src="image/abc.jpg"to <img
src="~/image/abc.jpg>, but the images in the user control, which is used in
the master page does not show at all.

What am I doing wrong?

--
Be Cool!
Oct 4 '06 #1
1 1744
ahh, I ripped my hair out quite awhile over this problem. It's quite
annoying.

Here's the catch, if you want to use the ~ in your img src's, you have
to tell asp to render the paths for the img src at the server, so...you
have to do: <img src="~/path/to/image.jpg" runat="server" />. This will
make asp render out the correct path to your images at runtime and the
images should show up.

Another way of doing it is (which is what I did), is to set a property
in your site.master called something like "ImagePath" , and do it like
so:

<img src="<%=ImagePa th%>image.jpg" />

and then in your code-behind you would have:

public static string ImageFolder {
get {
return HttpContext.Cur rent.Request.Ap plicationPath +
"img/";
}
}

That will work as well. I'm sure everyone has a different way of doing
it.

hope that helps!

Sean

thejackofall wrote:
I can use a good help here with what looks like a simple problem.

I have a control called Header.ascx in /Control/System directory, where / is
my web application directory.

The header is used in a master page called MasterPage.mast er in the /
directory.

I have a Default.aspx in / which uses the master page in the root. The user
control (which is really in the master page) in this page shows fine.

The problem is /directory1/earthquake.aspx . This page also uses the master
page in the / directory.

When this page is displayed, the control does not show like the Default.aspx
in the / directory.

So, I tried changing <img src="image/abc.jpg"to <img
src="~/image/abc.jpg>, but the images in the user control, which is used in
the master page does not show at all.

What am I doing wrong?

--
Be Cool!
Oct 4 '06 #2

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

Similar topics

3
4167
by: Not Me | last post by:
Hi, Just trying to get my head around tab controls, is there anywhere which would describe the structure of how they work? I seem to be ok so far, being able to check which page I'm on etc... but I'm at a loss when trying to access controls inside the tabs. If I try to access the form directly (!...etc.) I get an error that the form can't be found. I'm not sure how I can use parent/child relationships to get at the (sub)forms which...
10
2491
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of the functions and I can't find out how to do it. Here is an example of what I do and I get the following Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the...
4
4420
by: Ali | last post by:
I used to clear my page's control in Visual Studio 2003 using code like this: Dim c As Control For Each c In Page.Controls(1).Controls If TypeOf c Is TextBox Then CType(c, TextBox).Text = Nothing End If If TypeOf c Is DropDownList Then CType(c, DropDownList).SelectedIndex = 0 End If Next
6
2857
by: Naveen K Kohli | last post by:
I have couple of javascript files that need to be referenced for each content page. So I am trying to put them on Master page. The problem is that content pages are not on one level of the site. I have been trying to find a way to specify path to these JS files so that the actual path to these files correctly gets applied on the path at every level of the folder hierarchies. So far no luck... <script languaage=javascript...
13
6216
by: Michael | last post by:
I have setup a public variable in the Master Page "code-behind-file". Now I would like to set that value from the UserControl, but I can't seem to find a way to do this. Does anyone have any ideas? I'm basically trying to set it up so that I can keep the User infor (userid, ect) in the Masterpage so that other pages can access it. Thanks for any ideas. Michael
3
6415
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property BarLabelText. I now have a contentpage "FooBar.aspx", where "Bar.master" is the master page and in the content section has the control "Foo.ascx".
4
3973
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: hypTabAccount.InnerText = "blah" Now, what I want is the same in a content page that uses the Master Page. I have a Master Type in my Content page:
11
26571
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my server shows the c: \php5\pear path. I can't change it no matter what I do I also tried the...
3
1364
by: SAL | last post by:
I know there are probably some posts on this but I can't find any at the moment. I'm using VS 2005 on XP sp2. I'm using a master page and I have an image that I need to show but the path never really works correctly for all pages in the site. For instance, I have an Image folder with my image in it. My master page is in the Master folder, my default.aspx page is in the root
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6112
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.