Home > ASP.Net > Dynamic Copyright Method

Dynamic Copyright Method


Hi

try this example:

** Default.aspx

<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>" >
<head runat="server">
<title>Dynamic Copyright</title>
</head>
<body>
  <asp:Label ID="lblCopyright" runat="server" />
</body>
</html>

** Default.aspx.cs

public string DynamicCopyright(string YearSiteCreated)
{
    string DynamicCopyrightYear;
    //Is the current year equal to the year the site was created?
    if (DateTime.Now.Year.ToString() != YearSiteCreated) {
        //If not then concatenate year created and current year
        DynamicCopyrightYear = YearSiteCreated + "-" + DateTime.Now.Year.ToString();
    }
    else {
        DynamicCopyrightYear = YearSiteCreated;
    }
   
    string Copyright = "Copyright &copy; " + DynamicCopyrightYear + ". All rights reserved.";
    return Copyright;
}

protected void Page_Load(object sender, System.EventArgs e)
{
    lblCopyright.Text = DynamicCopyright(2006);
    //Use the created year as parameter
}

also you can try this:

Copyright 1998 - <%= DateTime.Now.Year.ToString() %> All rights reserved.

Hope this helps

Good Luck

Advertisements
Categories: ASP.Net Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: