Disable Browser Back Button

Push the history forward in the page you want to stop the user from going back to the previous page. 

  $(function() {
      window.history.forward();
  });

 

.NET Get Relative URL - ResolveClientUrl - MVC and WebForms

I needed to get the relative path to an image based on the URL in a static class.

Typically I would just use Page.ResolveClientUrl but that does not work in a class that does not inherit the page object.  Here is a snippet of code to cast HttpContext to a Page object. 

Webforms: This the code using in ASP.NET Webforms to get the relative URL in a base class
           
//Get the Full Path based on the page.             
//This will return /folder/image.jpg or something like ../folder/image.jpg
HttpContext CTX = HttpContext.Current;
System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler;
var ImageFullPath = page.ResolveClientUrl(folderName + @"/" + imageName);
MVC: This the code using in ASP.NET MVC to get the relative URL in a base class
           
//Create the Chart and save it
HttpContext CTX = HttpContext.Current;            
var ServerPath = CTX.Server.MapPath(ImgTempFolder);
var ImgName = c.makeTmpFile(ServerPath); //This is using ChartDirector. Replace your URL here.           

var VPath = VirtualPathUtility.ToAbsolute(ImgTempFolder) + ImgName;
return VPath;			

jQuery Sticky Footer

The footer shown on the screen shot below will remain at the bottom of the page even if you re-size the page.

This is great if your site has a content area that is not that tall, and the site is displayed on a large monitor. This way the footer will be pushed to the bottom of the screen.  If content exceeds the screen height it will push the footer off the screen. A little tweak with jQuery to make the context dive scroll if you want the footer to be truly "sticky."

Open the example below in a new window.

        function ResizeContent() {
            
            //Height of the available content area is  Page Height - (Header and Footer height. 
            //In this case 100px;
            var ContentHeight = Math.round($(window).height() - 100);
            ContentHeight = ContentHeight + "px";

            $("#MainContainer").css("min-height", ContentHeight);
        };


        $(function () {
            //Resize the content after page load or resize
             ResizeContent();

            window.onresize = function () {
                    ResizeContent();
              };
         });