Display a web application version on an ASP.NET master page…

To display a web application version on an ASP.NET master page:

1. Add an AssemblyInfo.cs file to the App_Code directory of a web application.

using System.Reflection;

[assembly: AssemblyVersion("2.1.1.2")]

2. Then in the Default.master.cs file add the following to the Page_Load event.

Assembly assembly = Assembly.Load("App_Code");

StringBuilder sb = new StringBuilder("Version ");

sb.Append(assembly.GetName().Version.ToString());

version.Text = sb.ToString();

3. In the Default.master file add the following where you want the version to display.

<asp:Label ID="version" CssClass="Version" runat="server" />

4. Finally add the following to the css style sheet.

.Version

{

   font-size:.4em;

   font-style:italic;

   margin-left:.2em;

}

Leave a comment