Home > Software design >  Changing text depending date using MVC Razor
Changing text depending date using MVC Razor

Time:12-06

I'm switch the text depending on dates and using JavaScript.

<div id="test"></div>

document.getElementById('test').innerHTML = new Date() > new Date('2021-12-05') ? 'A' : 'B';
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

but i want to ues a Razor to finish this thing, can give me any advise ?Thanks for your help, much appreciated.

CodePudding user response:

You can try to use this:

@if (DateTime.Now > new DateTime(2021, 12, 5))
{
    <div id="test">A</div>
}
else
{
    <div id="test">B</div>
}
  • Related