Friday, April 9, 2010

Restrict the Browser to get the Image from Cache Borwser

Sometime you notice When Image changed on server but browser display previous image from the cache.Its because image with the same name reside in the browser cache so when user request the Image it display the Image from cache.

If you want that image should be change on every request browser not display the image from cache and go to server of evey time for image.then below code will help you.

In C# Code Behind 

Img.ImageURl = "~images/Profile.jpg" + "?" + DateTime.Now.Ticks.ToString();

In Javascript
img.src = "~images/profile.jpg" + '?' + Math.random();

Tuesday, December 2, 2008

Stop the Scrolling of your page on the Page Refresh.

HELLO All

if you want to stop the scrolling of your page which carry the huge amount of data in asp.net then u can use following code after the Script manager.

There is one more option to stop a scrolling in web.config.
Maintainscrollpostion tag in web.config.
But its not work in my case A huge amount of images on my home page and these image refresh after some time and when it refresh page , page scroll on the any uncertain positions.

then i put that JavaScript code in master page after the script manger.

var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_beginRequest(beginRequest);
function beginRequest()
{

prm._scrollPosition = null;

}

hope it also help in your case.