GoingCranky
New Member
I have a file upload screen that lets a user upload an image and then display the image on the screen via an image control.<BR><BR>It works fine the first time they upload an image, but the second time they over write the first image it will not refresh the image control unless they hit the refresh button.<BR><BR>I have tried all kinds of things like response.redirecting back to the page, loading in a dummy image then loading in the uploaded image, etc, but none of these work.<BR><BR>I am guessing it is more of an IE issue where IE is caching the first image, any idea on how to stop it from caching the image so that each and every time the image is pulled from disk?... articles on ASP (classic) that tells about disabling the back button. It'll explain caching and how to avoid it.<BR><BR>Then, it shouldn't be too difficult to take that and apply it to .NET.<BR><BR>-DougI tried a bunch of those ideas, all of them that I could find actually but none seem to work.<BR><BR>I can not get IE to stop caching on a response.redirect back to the same page.<BR><BR>Anyone else have ideas?I had a similar caching problem with a datagrid.<BR>The page was a database editor. The first time the table was updated and the datagrid was binded with the new data from the table. But if you tried to update the table again it would not change the datagrid even though I binded the datagrid. With multiple updates the datagrid was always one step behind the data in the table.<BR><BR>I solved the problem by binding the datagrid and then response.redirect and binding the datagrid again on Page_Load.<BR><BR>If anyone has a better way of doing it let me know.<BR><BR><BR>Thank you<BR>Aaron<BR><BR>P.S. here is the database editor page:<BR><BR><%@ Import Namespace="System.Data" %><BR><%@ Import Namespace="System.Data.OleDb" %><BR><%@ Page Trace="False" %><BR><html><BR><BR><script language="VB" Debug="true" runat="server"><BR><BR> Dim oConnection As OleDbConnection <BR> Dim oCommand As OleDbCommand<BR> Dim myReader as OleDbDataReader<BR> <BR><BR> Sub Page_Load(Src As Object, E As EventArgs)<BR> <BR> 'Create the connection <BR> oConnection = New OleDbConnection(ConfigurationSettings.AppSettings("constring")) <BR> <BR> Message.InnerHtml = "Enter in Sql"<BR> <BR> if Len(Request.QueryString("sql")) > 0 then<BR> BindGrid(Request.QueryString("sql"))<BR> Message.InnerHtml = Request.QueryString("executed")<BR> Page.DataBind() <BR> end if <BR> <BR> If Not (IsPostBack)<BR> <BR> <BR> <BR> <BR> End If<BR> <BR> <BR> <BR> End Sub<BR><BR> Sub sql_Click(Sender As Object, E As EventArgs)<BR> <BR> Message.InnerHtml = sqltext.text<BR> <BR> if Instr(sqltext.text, "select ") then<BR><BR> BindGrid(sqltext.text) <BR> else<BR> oCommand = new OleDbCommand(sqltext.text, oConnection)<BR><BR> oCommand.Connection.Open() <BR> <BR><BR> Try<BR> <BR> oCommand.ExecuteNonQuery()<BR> Dim Sqlparts as Array <BR> Dim select_table as String = "select * from "<BR> if Instr(sqltext.text, "delete from ") then<BR> Sqlparts = Split(sqltext.text, " ") <BR> select_table = select_table & Sqlparts(2) <BR> else<BR> if Instr(sqltext.text, "update ") then<BR> Sqlparts = Split(sqltext.text, " ") <BR> select_table = select_table & Sqlparts(1) <BR> end if<BR><BR> if Instr(sqltext.text, "insert into ") then<BR> Sqlparts = Split(sqltext.text, " ") <BR> select_table = select_table & Sqlparts(2) <BR> end if<BR> end if<BR><BR> <BR> if Len(select_table) > 0 then<BR> BindGrid(select_table)<BR> Response.Redirect (Request.ServerVariables("Path_Info") & "?sql=" & select_table & "&executed=" & sqltext.text)<BR> end if<BR><BR> Message.InnerHtml = "Executed : " & sqltext.text<BR> <BR> Catch Exp As OleDbException<BR> 'Trace.Write("Exp.Message",Exp.Message)<BR> Message.InnerHtml = "ERROR: A OleDbException." & Exp.Message & "<BR>" & sqltext.text<BR> Message.Style("color") = "red"<BR> End Try<BR><BR> oCommand.Connection.Close()<BR> end if<BR> <BR><BR> End Sub<BR> <BR><BR><BR> Sub BindGrid(Sqlstr As String)<BR> <BR> Dim DS As DataSet<BR> Dim oCommand As OleDbDataAdapter<BR> oCommand = new OleDbDataAdapter(Sqlstr, oConnection) <BR> DS = new DataSet()<BR> Try<BR> oCommand.Fill(DS, "SqlTable")<BR> Dim Source As DataView = DS.Tables("SqlTable").DefaultView <BR> MyDataGrid.DataSource = Source<BR> MyDataGrid.DataBind()<BR> <BR> <BR> Catch Exp As OleDbException<BR> 'Trace.Write("Exp.Message",Exp.Message)<BR> Message.InnerHtml = "ERROR: A OleDbException." & Exp.Message & "<BR>" & sqltext.text<BR> Message.Style("color") = "red"<BR> End Try<BR><BR> <BR> End Sub<BR><BR></script><BR><BR><BR><body><BR><BR> <form runat="server"><BR> <BR> <BR> <BR> <p><span id="Message" EnableViewState="false" style="font: arial 11pt;" runat="server"/></p><BR> <BR><BR> <ASPataGrid id="MyDataGrid" runat="server" <BR> Width="800"<BR> BackColor="#ccccff"<BR> BorderColor="white"<BR> ShowFooter="false"<BR> CellPadding=3<BR> CellSpacing="0"<BR> Font-Name="Verdana"<BR> Font-Size="8pt"<BR> HeaderStyle-BackColor="#aaaadd"<BR> <BR> /><BR> <BR> <p><asp:textbox id="sqltext" value=http://aspmessageboard.com/archive/index.php/"" rows="10" cols="60" TextMode="Multiline" runat="server" /><BR><BR><input type="submit" OnServerClick="sql_Click" value="Execute Sql" runat="server"></p><BR> <BR> </form><BR><BR><BR></body><BR></html><BR><BR> <BR><BR> <BR>