开发者

Current Year in ASP.NET MVC 3

开发者 https://www.devze.com 2023-03-09 18:46 出处:网络
I want to add Copyright @ \'current_year\' to the footer (in cshtml file) of my page. I often made it using javascript but since I am using ASP.NET MVC 3 I would like to do this using ASP.

I want to add Copyright @ 'current_year' to the footer (in cshtml file) of my page. I often made it using javascript but since I am using ASP.NET MVC 3 I would like to do this using ASP.

I was trying construction like:

@response.write("Current Year: "&Year(Date))

But it didn't work in MVC 3 and I can't find solution tha开发者_JS百科t is working.


Try the following:

Copyright @@ @DateTime.Now.Year


In a .razor page in an ASP.NET Core application, e.g. within the <div> </div> of your footer, the following works too:

Copyright &#169 @DateTime.Now.Year

Added the copyright sign too and the double @@ is not needed in a razor page; it gives an error.

0

精彩评论

暂无评论...
验证码 换一张
取 消