473,396 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C#: Refresh image on page load

Eleven
19
Hi everybody,

I'm trying to load a different logo depending on who's logged in but the code doesn't seem to be working, well, it only works after i've rebooted my PC. Even when I log out it doesn't show the image its supposed to show for an un-authenticated user.
I'm guessing its something to do with refreshing the page.. but even when I manually refresh the page it doesn't work.

Hope someone can help me asap, i've spent too much time on this already.

Thanks

Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.   {
  3.  
  4.     if (!Page.User.Identity.IsAuthenticated)
  5.       BankLogoImage.ImageUrl = SmartecLogoImage.ImageUrl;
  6.  
  7.       //Showing logged in user's bank logo
  8.       if (Global.LoggedInUser.FkBanksID.Value == 1)
  9.           BankLogoImage.ImageUrl = "~/Images/ABSACashProtector.jpg?";
  10.       else
  11.           if (Global.LoggedInUser.FkBanksID.Value == 2)
  12.               BankLogoImage.ImageUrl = "~/Images/NedBankLogo.jpg?";
  13.       else
  14.           if (Global.LoggedInUser.FkBanksID.Value == 3)
  15.               BankLogoImage.ImageUrl = "~/Images/SmartecLogo.jpg?";
  16.  
  17.  
  18.  
  19.  
  20.   }
  21.  
Mar 26 '08 #1
6 5387
BankLogoImage.ImageUrl = SmartecLogoImage.ImageUrl;

When you specify the asp Image tag you need to state the attribute 'ImageUrl=""' otherwise server side will not recognise it as being defined- this is most likely why you cannot change the value of it from the server. If you are using a regular html tag with the 'src' attribute then this will fail...

Can you show your html code?
Mar 27 '08 #2
Plater
7,872 Expert 4TB
Is your page being cached? What if you change the settings for that page to be not cached?
Mar 27 '08 #3
Eleven
19
BankLogoImage.ImageUrl = SmartecLogoImage.ImageUrl;

When you specify the asp Image tag you need to state the attribute 'ImageUrl=""' otherwise server side will not recognise it as being defined- this is most likely why you cannot change the value of it from the server. If you are using a regular html tag with the 'src' attribute then this will fail...

Can you show your html code?
Here's my HTML Code, i did specify the ImageUrl attribute

Expand|Select|Wrap|Line Numbers
  1. <table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
  2.                     <tr>
  3.                         <td align="left" style="height: 50px; padding-left: 4px; border-bottom: #cccccc 2pt dotted;">
  4.                             <asp:Image ID="SmartecLogoImage" runat="server" Height="30px" ImageUrl="~/Images/SmartecLogo.PNG"
  5.                                 Width="200px" /></td>
  6.                         <td align="center" style="height: 50px; border-bottom: #cccccc 2pt dotted;">
  7.                             <asp:Label runat="Server" ID="PageTitleLable" Font-Bold="True" CssClass="PageHeader"></asp:Label>
  8.                         </td>
  9.                         <td align="right" style="height: 50px; padding-right: 4px; border-bottom: #cccccc 2pt dotted;">
  10.                             <asp:Image ID="BankLogoImage" runat="server" Height="30px" ImageUrl="~/Images/ABSACashProtector.PNG"
  11.                                 Width="200px" ImageAlign="Right" /></td>
  12.                     </tr>
  13.                     <tr>
  14.                         <td align="left">
  15.                             <asp:LoginName ID="LoginName1" runat="server" Font-Bold="False" FormatString="Welcome back <b>{0}</b>"
  16.                                 CssClass="LoginUser" />
  17.                         </td>
  18.                         <td align="right">
  19.                             &nbsp;</td>
  20.                         <td align="right">
  21.                         </td>
  22.                     </tr>
  23.                 </table>
  24.  
Apr 3 '08 #4
Eleven
19
Is your page being cached? What if you change the settings for that page to be not cached?
Plater, could you please explain how i'd go about making the page not chached? I don't know much about that.

Thanks!
Apr 3 '08 #5
Plater
7,872 Expert 4TB
If you can (either in front end code or the backend code in the page_load), add the datetime number to the end of the request, sorta like this:

"/Images/SmartecLogo.PNG?t="+DateTime.Now.Ticks.ToString();


This frequently "tricks" browsers into thinking it is requesting a different page since the query string is different, although it is still requesting the same file.
Apr 3 '08 #6
Eleven
19
If you can (either in front end code or the backend code in the page_load), add the datetime number to the end of the request, sorta like this:

"/Images/SmartecLogo.PNG?t="+DateTime.Now.Ticks.ToString();


This frequently "tricks" browsers into thinking it is requesting a different page since the query string is different, although it is still requesting the same file.
Thank you, i'll try it out.
Apr 3 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Conax | last post by:
Hi there, My boss is hoping that I can come up with a page that displays some information. The information will always be displayed on specific part of the page, with auto refresh. But he...
2
by: Gary \(Girish\) | last post by:
Hello: I am using SA-FileUp to enable members to upload their product images to my ISP sever. When member uploaded a new image file, the file name is replaced with the member ID and the old file...
1
by: Luna Kwok | last post by:
Hello, I have a very strange problem. When I load up a page, all the images look fine, but when I refresh the page, all the images become dead. This happens on both IE and netscape. I have...
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
5
by: Selden McCabe | last post by:
I have a page that displays a picture. In the page load I figure out which image and then do a StudentPicutre.imageurl = <some file name> But if you use the browser's back button, enter...
2
by: Just D. | last post by:
All, How should we refresh the current aspx frame? I disabled caching using this command on Page_Load(): Response.Cache.SetCacheability(HttpCacheability.NoCache); but it didn't help. The...
0
by: Vladi | last post by:
Hello everybody, I have a asp.net 1.1 page which has the following controls: 4 Images whose src points to an image.aspx file which returns a different jpg from a DB 1 flash object on top of those...
2
by: J-T | last post by:
Hello, I have an iframe which its scr is set to show a url (am image) .I am put this iframe on a user control and I am loading that user control dynamically to my Default.aspx.Now I need to...
9
by: TCORDON | last post by:
I have a user control that contains 2 image buttons, when you click one of them, both must change the image source, the thing is that the first time you click any one of them the page appears to do...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.