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
I'm wondering if it's possible to put a foreach loop inside a href?
The reason is because I want a link to be able to link to multiple emails and I don't know how to do it otherwise.
I'm using HTML, Razor
I tried doing like this:
@foreach (var syv in syvs) { <a href="mailto:@syv.ePost" target="_top">@syv.ePost</a> }
But now it displays all the mails. What I want is one link that mails to all.
I need something that only loops the mails inside the link, but I can't figure out how
I appreciate any help
Hi Johan,
Something like the below may be something you'd want. The code below loops through every ePost and creates a string. Then one link is outputted containing all ePost email addresses.
@{ var href = string.Empty; foreach (var syv in syvs) { href = string.format("{0}, {1}", href, syv.ePost); } } <a href="mailto:@href">Send Email</a>
Hope that helps.
Thanks, Dan.
Thank you, Dan.
How do I add a comma after each mail?
I tried it @syv.ePost + ";" but it didn't work
@syv.ePost + ";"
By using a bit of LINQ, you should be able to do it like:
string href = String.Join(";", from syv in syvs select syv.ePost);
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
For each loop inside a href?
I'm wondering if it's possible to put a foreach loop inside a href?
The reason is because I want a link to be able to link to multiple emails and I don't know how to do it otherwise.
I'm using HTML, Razor
I tried doing like this:
But now it displays all the mails. What I want is one link that mails to all.
I need something that only loops the mails inside the link, but I can't figure out how
I appreciate any help
Hi Johan,
Something like the below may be something you'd want. The code below loops through every ePost and creates a string. Then one link is outputted containing all ePost email addresses.
Hope that helps.
Thanks, Dan.
Thank you, Dan.
How do I add a comma after each mail?
I tried it
@syv.ePost + ";"
but it didn't workBy using a bit of LINQ, you should be able to do it like:
is working on a reply...