SQL Server Functions - Get First and Last Day in a Month

CREATE FUNCTION [dbo].[f_get_first_date_of_month] 
(
    @Date DATETIME
)
RETURNS DATETIME
AS
BEGIN

   return DATEADD(d, 0, DATEADD(m, DATEDIFF(m, 0, @Date), 0))
END
CREATE FUNCTION [dbo].[f_get_last_date_of_month] 
(
    @Date DATETIME
)
RETURNS DATETIME
AS
BEGIN

    RETURN DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, @Date) + 1, 0))

END

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;