 |
| ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 6th, 2009, 10:27 AM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Refreshing a .img Image
I have a dynamic .img image in the footer on my MasterPage. It displays the number of visits as a bitmap that has been created in a control.ascx file. It displays OK when the Default page is displayed but not when a switch is made to one of the other pages. It just shows as a box with the red x in it. It appears that this is because the control.ascx is not called each time a new page is called.
How do I refresh the .img control every time a new page is displayed?
__________________
Thanks, wagham
|
|

May 6th, 2009, 02:08 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
My first guess -- the URL of the image is not being resolved correctly, so it can't find the image. It would be easy to tell if this is the case by examining the rendered source with something like Firebug.
Hard to tell without seeing it happening on a live site, or without access to your code.
|
|

May 6th, 2009, 02:49 PM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
The code is as follows:
Code:
<img src="Counter/counter.aspx?src=Digits.gif&digits=5&id=RLSBC" alt="Visit Counter"/>
As I say, it is created dynamically, it is not a static url. When a new page is displayed, counter.aspx (not .ascx as in my original post) is not re-executed. Therefore the counter is not updated. I expected the original graphic to still be displayed, but apparently not.
__________________
Thanks, wagham
|
|

May 8th, 2009, 09:13 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
|
|
Read what lee said...
Read what Lee said. Just because the image is dynamically rendered you are still calling a page to render it for you so it's possible when you change from page to page your pages aren't reading the directory structure as you intend it to thus it can't find the rendering page. Perhaps you could try something like
<img src="../Counter/counter.aspx?src=Digits.gif&digits=5&id=RLSBC" alt="Visit Counter"/>
that way you sort of guarantee that you are looking in the parent directory first?
__________________
Jason Hall
Follow me on Twitter @jhall2013
|
|

May 19th, 2009, 04:24 PM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
First let me apologise most profusely to Lee for the dismissive tone of my last post. alliancejhall was quite correct to pull me up. It IS something to do with the rendering of the URL, but I still don't know what.
If I use alliancejhall's suggestion
<img src="../Counter/counter.aspx?src=Digits.gif&digits=5&id=RLSBC" alt="Visit Counter"/>
with the .. before the /Counter, I get the correct display on all pages apart from my Default page. Now that doesn't display correctly.
The default page is in the root directory of my site with the other pages one directory down. The Counter directory is also one level down from the root. How do I code the src=" to display it correctly on all pages?
__________________
Thanks, wagham
|
|

May 19th, 2009, 04:40 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
Have you tried this?
Code:
<asp:Image ID="Image1" runat="server" ImageUrl="~/Counter/counter.aspx?src=Digits.gif&digits=5&id=RLSBC" AlternateText="Visit Counter" />
|
|

May 20th, 2009, 11:53 AM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Counter still not displaying
Thank you for your response. I have tried the asp:image control as you suggest, and while it works perfectly when I create the website within Visual Studio, it does not work when I build and upload it to my host machine. The source of the image looks correct on all pages. At least, it is very similar to other images that do display correctly. The Counter directory is at the same level as the Images directory.
The address of my site is www.royalleamingtonspabc.org.uk
__________________
Thanks, wagham
|
|

May 20th, 2009, 12:27 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
Well, now that you've given the public URL, I have been able to discover more about what's happening, and why it works on your dev machine and not your host.
The asp:Image works correctly in that it seems to properly resolve the URL. However, you have a security issue on your host account.
When I navigate directly to http://www.royalleamingtonspabc.org....its=5&id=RLSBC
I get the following error:
Access to the path 'C:\inetpub\vhosts\royalleamingtonspabc.org.uk\htt pdocs\counter\RLSBC.txt' is denied.
You seem to be attempting to create a writable file called RLSBC.txt in the \counter directory, but you have not granted the ASP.NET worker process write access to the \counter directory.
So, you need to grant read/write/modify permissions on the \counter directory to the ASP.NET worker process, and you should be good to go.
You should be able to do that via your hosting account control panel, depending on who your host is. If you don't know how to do that, contact your host and ask them how to modify permissions for a site directory.
Last edited by Lee Dumond; May 20th, 2009 at 12:33 PM..
|
|
The Following User Says Thank You to Lee Dumond For This Useful Post:
|
|
|

May 20th, 2009, 04:59 PM
|
|
Authorized User
|
|
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Thank You
Thanks, I don't think I would have found that in a month of Sundays. As I am self taught, I do not yet understand the finer points of how to find out what's going on when things go wrong. This thread has taught me a lot about debugging toolbars, but I still wouldn't have thought of trying to open the counter control. Again my apologies for the earlier post and thank you.
__________________
Thanks, wagham
|
|

May 20th, 2009, 05:26 PM
|
 |
Wrox Author
|
|
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
|
|
Yes, self-taught here also. No problem, glad to help you get it figured out.
|
|
The Following User Says Thank You to Lee Dumond For This Useful Post:
|
|
|
 |