Last post Dec 18, 2006 05:44 AM by jessjing
Dec 07, 2006 04:09 AM|vatsaldesai24|LINK
i want to refresh page automatically when i click on submit button. and i neet that at server side. is it possible? if anyone knows then do reply.
Dec 07, 2006 04:35 AM|pkellner|LINK
I assume the submit button is an asp:button. If so, you can put in the codebehind a "Response.redirect("yourself.aspx"); replace yourself.aspx with the web page that has the button. this will cause a Get to be sent rather than a post an a fresh page with
no baggage will be generated.
Dec 07, 2006 05:28 AM|vatsaldesai24|LINK
thanx for your reply. my problem is....
i hv an fileuplod control(<input type="file">). and one image control (<img src="mypath">). when i upload the image from fileupload control. the image control not showing me the new uploaded image. it shows only old image. to see the new uploaded image i
need to refresh the page. and i try the response.redirect("yourself.aspx"). but its not working...
do u have any other idea to do this???
Dec 07, 2006 03:05 PM|pkellner|LINK
Dec 08, 2006 03:39 AM|vatsaldesai24|LINK
on page load event i load a image in image contrlo. i.e imgPhoto.src = "../images/image1.jpg".
now what i m doing is i never change the src property of image control. insted of i just replace the image1.jpg. (i.e i change the uploaded image name to image1.jpg remove the old image1.jpg and put the new image1.jpg. this all done automatically on server.
now when i click on submit button on web page page post back, upload the selected image. rename it to image1.jpg. remove the old one and put the new one. and come back to my page. new image is uploaded correctly. replace the old one is also done. so on server
the image is changed. but not on iffect on client side. but when i refresh the page manualy then the image is chang.
so in all the process i m not changing the image path to another image but i m changing the real image on server only.
Dec 08, 2006 04:29 AM|jessjing|LINK
use <asp:Button> and <asp:image>
protected void Button1_Click(object sender, EventArgs e)
string fileName=FileUpload1 .FileName ;
FileUpload1.SaveAs("e:\\" + fileName);
Image1.ImageUrl = "e:\\"+fileName ;
<asp:Image ID="Image1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:FileUpload ID="FileUpload1" runat="server" /></div>
it works ok
Dec 08, 2006 05:21 AM|vatsaldesai24|LINK
hay thanx for your reply. but i got the soln for my problem. actually i hv to add timestamp on loading image in image control. it works nice. see this
strNewTimeStamp = strNewTimeStamp.Replace(":", "")
strNewTimeStamp = strNewTimeStamp.Replace("/", "")
imgPhoto.Src = "../images/imagename.jpg" ' here u set static imagesource
imgPhoto.Src = imgAlbum.Src & "?ts=" & strNewTimeStamp ' At last just write this. and enjoy....
Each time u change image on server(i.e upload via fileuploadcontrol.) u need to run this code...
Dec 08, 2006 05:25 AM|jessjing|LINK
thank you very much for sharing your solutions with us
Dec 17, 2006 07:19 PM|rolando2000|LINK
Hi. I have same problem as you. I use Image and button server controls. when I bind picture to image it does not bind the lates picture. So how do you use the Timestamp for this in C#. Any idea?.
Thanks in advance
Dec 18, 2006 03:07 AM|vatsaldesai24|LINK
sorry but i never try it in c# before. but i think it should also work in c#. did you try that vb.net code in c#? if its still not working then search on google for timestamp. don't know why but it shoud work in c# also....
Dec 18, 2006 05:44 AM|jessjing|LINK
hi, in c#
string strNewTimeStamp=string .Format(System.DateTime,UtcNow,"MMddyyyyhhmmsstt")
imgPhoto.Src = "../images/imagename.jpg" // here u set static imagesource
imgPhoto.Src = imgAlbum.Src + "?ts=" +strNewTimeStamp //At last just write this. and enjoy....