but if you are manipulating date functions, you are probably better putting everything into a DateTime value - and using the time manipulation functions (e.g date.AddHours(-1) ) as that will copy with all the strange things (like taking an hour from 24 mins past midnight on the first of a month.).
I'm sorry but its not working for me. Maybe that's because value starttijdwebinar isn't a DateTime?
Here's the entire code:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
var startNodeId = 1819;
var startNode = Umbraco.Content(startNodeId);
var currentdate = DateTime.Now.ToString("yyyy-MM-dd");
var currenttime = DateTime.Now.ToString("HHmm");
var selection = startNode.Webinarcontentgrid;
int i = 1;
foreach (var item in selection){
if(item.contentgriddate >= currentdate && item.eindtijdwebinar > currenttime ){
if(@i <= 1){
var promotietijdwebinar = (item.GetValue("starttijdwebinar")-100);
if(item.starttijdwebinar > currenttime && @promotietijdwebinar > currenttime){
<div class="wrapper">
<img src="https://webinar.leadkeeper.net/media/129038/background.jpg" alt="background img Microsoft Sessies" />
<div class="streammessage">
<img src="https://webinar.leadkeeper.net/media/129040/icon_wachten.png" alt="not started" />
<h1>De uitzending op deze pagina is nog niet begonnen.</h1>
<p>Inloggen is mogelijk op <strong>@item.contentgriddate</strong> vanaf <strong>@promotietijdwebinar</strong>.<br />
De uitzending start om <strong>@item.starttijdwebinar</strong>.</p>
</div>
</div>
}
} i++;
}
}
}
Values eindtijdwebinar and starttijdwebinar are plain text values.
also, if you only care about how it's displayed you only need to put the formmating on the promotietijdwebinar value in the paragraph ?
<h1>De uitzending op deze pagina is nog niet begonnen.</h1>
<p>Inloggen is mogelijk op <strong>@item.contentgriddate</strong> vanaf <strong>@promotietijdwebinar</strong>.<br />
De uitzending start om <strong>@item.starttijdwebinar</strong>.</p>
Razor - Adding a comma after 2 characters of a string
Hi guys,
Quick question. I'd like to add a
In between a string i have. Now i have a string that goes like this:
This outputs into:
Now i'd like to make it so this will output with a ; after the first 2 characters like this:
Do you guys have any quick suggestions?
hi.
will output in the correct format.
but if you are manipulating date functions, you are probably better putting everything into a DateTime value - and using the time manipulation functions (e.g
date.AddHours(-1)
) as that will copy with all the strange things (like taking an hour from 24 mins past midnight on the first of a month.).Hi Kevin,
Thank you for your response. Might be a stupid question but how do i work this into my code?
I've made it so that i can now call a var like this:
Can i format this with string.format?
hi ,
i am not 100% sure where you are in your code and what object
item
is but...would work i think - but it would make
promotietijdwebinar
a string, when it's previously an int - this might not be an issue but if it is...replacing it where you write it out. is the other option ...
could become
and this would also work.
Kevin
Hi Kevin,
I'm sorry but its not working for me. Maybe that's because value
starttijdwebinar
isn't a DateTime?Here's the entire code:
}
Values
eindtijdwebinar
andstarttijdwebinar
are plain text values.Hi,
you have an @ in the if line .
so remove that.
also, if you only care about how it's displayed you only need to put the formmating on the
promotietijdwebinar
value in the paragraph ?so
should be enough ?
this formatting only works when the value is an int.
so either check the values are int,s or see if you can get them by type (for example with
item.GetValue<int>("thing")
)or you could parse them
int.Parse(value)
if they are strings.but i would have checking around a lot of this, because things like parse could fail..
is working on a reply...