Know your version of Web Application

Once the web application is published to production, after a while it becomes difficult to know exactly which version is in production. One of the way to find it without any ambiguity is to flash the version number on the footer tag next to copyright text.

Code in aspx page

<div id="AssemblyVersionInfo">
  <%=AssemblyVersionInfo%>
<div>

Code in Codebehind page

 public string AssemblyVersionInfo { get; set; }

 protected void Page_Load(object sender, EventArgs e)
 {
      SetAssemblyVersionInfo();
 }

 private void SetAssemblyVersionInfo()
 {
    Assembly assembly =
Assembly.LoadFrom(
Server.MapPath("bin\\<ApplicationDllName>.dll"));
Version ver = assembly.GetName().Version;
AssemblyVersionInfo = "Version : "
   + ver.Major.ToString()
   + "." + ver.Minor.ToString()
   + "." + ver.Build.ToString()
   + "." + ver.Revision.ToString();
 }

Quick loading image for all ajax call

We have very common need of displaying some loading animation while ajax call is going on background. There have been lots of help out there. Here is another repetitive version of it. It should work to any of the application out there.

<script language="javascript">
$('#loadingDiv')
 .hide() // hide it initially
 .ajaxStart(function() {
 $(this).show();
 })
 .ajaxStop(function() {
 $(this).hide();
 });
</script>

$('#loadImageLocation').prepend('<div 
id="loadingDiv" ><img id="theImg" 
src="<path of loading image>" /></div>');

In the above code make following changes

  1. Add a JQuery reference to your page.
  2. Change <path of loading image> to actual image url of loading animated image.

Happy JQuery!