Home > database >  How to append c# variable in src tag of script in MVC razor template?
How to append c# variable in src tag of script in MVC razor template?

Time:10-01

   @{
       string clientId = "1234567"

      <script id="AbcClient" src="https://myspecialjs/@clientId/client.js" type="text/javascript" 
      async></script>
   }

How do I append variable "clientId" in src tag after "myspecialjs/" ?

This is an MVC razor template.

CodePudding user response:

@{
    string clientId = "1234567";
    string url = "https://myspecialjs/"   clientId   "/client.js";
    <script id="AbcClient" src=@url type="text/javascript" 
    async></script>
    @url
}
  • Related