Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I'm struggeling to insert value to a querystring in razor: Here's what I've got:
rowTemplate = rowTemplate.Replace(string.Concat("{{url}}"), Umbraco.Content(Convert.ToInt32(annonce.Id)).NiceUrl());
What I want to do is to insert this after .NiceUrl()?date=DateTime.Now.ToString("dd-MM-yyyy"));
But that doesn't work.
I get this error: Compiler Error Message: CS1003: Syntax error, ':' expected
Can anybody help me out here?
Regards Palle
Hi Palle,
I can see that you have 2 closing brackets for the DateTime.Now.ToString("dd-MM-yyyy")) but only one open bracket
Try to use this code snippet below.
@{ var currentDate = DateTime.Now.ToString("dd-MM-yyyy"); <a href="@Umbraco.NiceUrl(CurrentPage.Id)?date=@currentDate">@CurrentPage.Name</a> }
Hope this helps, or can help you a step further.
/Dennis
Hi Dennis.
Thanks for your reply.
No luck I'm afraid. Get the same error.
The code is in a cs. file in the App_Code folder if that should do any difference.
/Palle
Okay try to see to see Kevin Jump“s comment in this thread.
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/68294-add-current-query-string-to-niceurl-and-niceurlwithdomain-methods
Hope this helps,
I got it working with this: rowTemplate = rowTemplate.Replace(string.Concat("{{url}}"), string.Concat(Umbraco.Content(Convert.ToInt32(annonce.Id)).Url(), "?date=", DateTime.Now.ToString("yyyy-MM-dd")));
Just if anyone else could use it.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Add querystring to url razor
Hi,
I'm struggeling to insert value to a querystring in razor: Here's what I've got:
rowTemplate = rowTemplate.Replace(string.Concat("{{url}}"), Umbraco.Content(Convert.ToInt32(annonce.Id)).NiceUrl());
What I want to do is to insert this after .NiceUrl()?date=DateTime.Now.ToString("dd-MM-yyyy"));
But that doesn't work.
I get this error: Compiler Error Message: CS1003: Syntax error, ':' expected
Can anybody help me out here?
Regards Palle
Hi Palle,
I can see that you have 2 closing brackets for the DateTime.Now.ToString("dd-MM-yyyy")) but only one open bracket
Try to use this code snippet below.
Hope this helps, or can help you a step further.
/Dennis
Hi Dennis.
Thanks for your reply.
No luck I'm afraid. Get the same error.
The code is in a cs. file in the App_Code folder if that should do any difference.
/Palle
Hi Palle,
Okay try to see to see Kevin Jump“s comment in this thread.
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/68294-add-current-query-string-to-niceurl-and-niceurlwithdomain-methods
Hope this helps,
/Dennis
Hi Dennis.
I got it working with this: rowTemplate = rowTemplate.Replace(string.Concat("{{url}}"), string.Concat(Umbraco.Content(Convert.ToInt32(annonce.Id)).Url(), "?date=", DateTime.Now.ToString("yyyy-MM-dd")));
Just if anyone else could use it.
/Palle
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.