The codesnippet below creates a dynamic copyright and on the Page_Load event the text property of the label 'lblCopyright' displays the returned value of the function DynamicCopyright. You could incorporate the code snippet below into your Master Page so that the dynamic copyright is site-wide.
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Function DynamicCopyright(ByVal YearSiteCreated As String) As String
Dim DynamicCopyrightYear As String
'Is the current year equal to the year the site was created?
If DateTime.Now.Year.ToString() <> YearSiteCreated Then
'If not then concatenate year created and current year
DynamicCopyrightYear = YearSiteCreated & "-" & DateTime.Now.Year.ToString()
Else
DynamicCopyrightYear = YearSiteCreated
End If
Dim Copyright As String = "Copyright © " & DynamicCopyrightYear & ". All rights reserved."
Return Copyright
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
lblCopyright.Text = DynamicCopyright(2006) 'Use the created year as parameter
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Dynamic Copyright</title>
</head>
<body>
<asp:Label ID="lblCopyright" runat="server" />
</body>
</html>
Get the best asp web hosting provider now and save 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.