I am trying to add a url.action method to an anchor tag dynamically but for some reason it keeps adding a space between the url.action part and my action name.
here is the javascript code:
var contentString = '<h3 class="info-window-title">Name of NPO</h3>' + '<a href="@Url.Action("Wallet","Wallet")">Click me to donate!</a>';
here is the code once i inspect the anchor tag using chrome dev tools:
<a href="@Url.Action(" wallet","wallet")">Click me to donate!</a>
It keeps adding a space before wallet and i have no idea why. any help would be much appreciated.
I could see some problem in string concatenation, you have to use backslash character for double quote /single quote inside string literal
var contentString = '<h3 class="info-window-title">Name of NPO</h3>' +
'<a href=\"@Url.Action(\'Wallet\',\'Wallet\')\">Click me to donate!</a>';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.