本文介绍了ASP.NET图像控件未显示最新上传的照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Page_Load
中,我将图像分配给:
Hi,
In Page_Load
, I am assigning an image to:
<asp:image id="imgPhoto" runat="server" xmlns:asp="#unknown"></asp:image>
这是我的代码:
page_load
===========
Here is my code:
page_load
============
string photo = siteurl + DBUtilities.ExecuteScalar(DBConnections.GetSQLConnectionString(), CommandType.Text, "select photo from visitors_images where visitor_id='" + Request.QueryString["visitor_no"].ToString() + "'").ToString();
if (IsExists(photo))
imgPhoto.ImageUrl = photo;
else
imgPhoto.ImageUrl = "~/includes/images/no_person.jpg";
Submit_button
============
Submit_button
=============
fulPhoto.SaveAs(Server.MapPath("~/includes/visitors/" + IMGNAME));
DBUtilities.ExecuteNonQuery(DBConnections.GetSQLConnectionString(), CommandType.Text, "UPDATE visitors_images SET photo='" + IMGNAME + "' WHERE visitor_id='" + Request.QueryString["visitor_no"].ToString() + "'");
Response.Redirect(Request.RawUrl.ToString());
但是,如果我手动刷新,它将显示最新照片.能否请您提出一些建议.
谢谢!
But, if I refresh manually, it shows the latest photo. Can you please give some suggestion.
Thanks!
推荐答案
Random r = new Random();
int RandomNumber = r.Next();
Response.Redirect(Request.RawUrl.ToString()+?r =" + RandomNumber.ToString();
Response.Redirect(Request.RawUrl.ToString()+"?r=" + RandomNumber.ToString();
这篇关于ASP.NET图像控件未显示最新上传的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!