Wrox Programmer Forums
|
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
 
Old May 6th, 2009, 10:27 AM
Authorized User
 
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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
 
Old May 6th, 2009, 02:08 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

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.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 6th, 2009, 02:49 PM
Authorized User
 
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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
 
Old May 8th, 2009, 09:13 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default 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
 
Old May 19th, 2009, 04:24 PM
Authorized User
 
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default

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
 
Old May 19th, 2009, 04:40 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

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" />
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 20th, 2009, 11:53 AM
Authorized User
 
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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
 
Old May 20th, 2009, 12:27 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

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.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}

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:
wagham (May 20th, 2009)
 
Old May 20th, 2009, 04:59 PM
Authorized User
 
Join Date: Sep 2008
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
Default 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
 
Old May 20th, 2009, 05:26 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Yes, self-taught here also. No problem, glad to help you get it figured out.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
wagham (May 21st, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Img doesn't display peter2004 HTML Code Clinic 9 September 16th, 2009 08:20 PM
How to upload image without refreshing page in IE malay mehta Beginning PHP 3 March 6th, 2007 10:25 AM
img tag not loading austinf XSLT 0 June 13th, 2006 04:41 AM
img not refreshing austinf XSLT 1 June 13th, 2006 03:55 AM
refreshing XML withour refreshing the page sasidhar79 XML 1 January 12th, 2005 05:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.