Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 5th, 2006, 11:28 PM
Registered User
 
Join Date: Sep 2006
Location: , , New Zealand.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Refresh imagebutton

I have a problem with a web page that contains an imagebutton that displays a map generated by GDI commands and selected data from a gridview. The map is ‘live’ so that selecting a record in the gridview will highlight the point on the imagebutton, and vice versa. The map can also be zoomed and panned, so the image has to be constantly updated. The way I am doing this is to recreate the graphics, save the image as a bitmap file on the server and then reload it with ImageButton1.ImageUrl = "filename.bmp".

The problem is that while a new version of the image has been created and saved, it is not displayed – not unless I force a refresh. This generates the annoying msgbox “The page cannot be refreshed without resending the information…”. I presume this behaviour is due to caching, but other parts of the page are updated correctly without needing to refresh. For example a textbox can display the coordinates of the point clicked on the imagebutton. It seems to be only the image that is not updated.

So my questions are: 1. Is there a more direct way of updating the image on an imagebutton without having to save it to a file and then reload it? or 2. How can I force the latest version of the image to be retrieved from the server and displayed on the page? A solution of the first type would be preferable because that might also get around the problem of multiple visitors to the site generating multiple images.

I’m not sure if this is a “beginner” problem, but I am certainly a beginner when it comes to ASP.NET. Does anyone have any ideas?



Reply With Quote
  #2 (permalink)  
Old September 13th, 2006, 04:40 PM
Registered User
 
Join Date: Sep 2006
Location: , , New Zealand.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No response to this one yet but I have found a solution, so if anyone is interested:

The problem I had was an imagebutton whose image was created and updated by user actions. A jpg file was saved to the server and then loaded into the imagebutton by code. Unfortunately the new version of the image is not displayed without forcing a refresh. What I discovered was that the image for an imagebutton does not have to be a jpg, gif or other standard graphic file – it can be another aspx page (this is not immediately obvious from the standard resources). So now I draw the image onto an otherwise empty aspx page using objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg). In the main page this is accessed with ImageButton1.ImageUrl= "somepage.aspx?someparameters". And this way it works! I think the reason is that somewhere along the line, aspx files are assumed to be dynamic and so are not cached (unless you overrule this) but other files, like images, are assumed to be static and so are cached (possibly at several levels?) And there doesn’t seem to be a way to change this because there is no way to put directives like Response.CacheControl = "no-cache" into a jpg file. Am I correct?

I’m still not totally happy with this solution though because I have to pass a lot of data between aspx pages (or generate it twice) so if anyone knows of a more elegant (and efficient) way I would be grateful.



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help in LoginStatus and Asp:ImageButton [Mini kamii47 ASP.NET 2.0 Basics 0 September 1st, 2007 04:24 PM
imagebutton click handling timtomtomkat ASP.NET 2.0 Basics 3 May 23rd, 2007 06:52 AM
imagebutton click handling timtomtomkat ASP.NET 2.0 Professional 0 May 22nd, 2007 04:53 PM
asp:imagebutton link to New url nawski ASP.NET 1.0 and 1.1 Basics 12 November 5th, 2006 07:50 PM
Display imagebutton in Repeater monika.vasvani ASP.NET 1.0 and 1.1 Basics 0 August 24th, 2006 02:07 AM



All times are GMT -4. The time now is 08:55 PM.


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