zoukankan      html  css  js  c++  java
  • HTML中夹杂CODE

    @{
       // Working with numbers
       var a = 4;
       var b = 5;
       var theSum = a + b;

       // Working with characters (strings)
       var technology = "ASP.NET";
       var product ="Web Pages";

       // Working with objects
       var rightNow = DateTime.Now;
    }

    <!DOCTYPE html>
    <htmllang="en">
     
    <head>
       
    <title>Testing Razor Syntax</title>
       
    <metacharset="utf-8"/>
       
    <style>
        body
    {font-family:Verdana;margin-left:50px;margin-top:50px;}
        div
    {border:1px solid black;width:50%;margin:1.2em;padding:1em;}
        span
    .bright {color:red;}
       
    </style>
     
    </head>
    <body>
     
    <h1>Testing Razor Syntax</h1>
     
    <formmethod="post">

       
    <div>
         
    <p>The value of <em>a</em> is @a.  The value of <em>b</em> is @b.
         
    <p>The sum of <em>a</em> and <em>b</em> is <strong>@theSum</strong>.</p>
         
    <p>The product of <em>a</em> and <em>b</em> is <strong>@(a*b)</strong>.</p>
       
    </div>

       
    <div>
         
    <p>The technology is @technology, and the product is @product.</p>
         
    <p>Together they are <spanclass="bright">@(technology + " " + product)</span></p>
      
    </div>

      
    <div>
        
    <p>The current date and time is: @rightNow</p>
        
    <p>The URL of the current page is<br/><br/><code>@Request.Url</code></p>
      
    </div>

     
    </form>
    </body>
    </html>

    在html中夹杂code:@(),如果只是一个变量,直接 @var即可,如果有计算,即为:@(technology + " " + product)

  • 相关阅读:
    记录一次线上优化流程
    php ignite 使用问题记录
    invalid contrller specified 错误分析及解决
    koa 2 的 async 和 await 语法
    koa 2 的安装
    vue 自定义组件 v-model双向绑定、 父子组件同步通信的多种写法
    VS2019专业版和企业版激活密钥
    RE:ゼロから始める PKU 生活 episode 2
    CSP-S 2020 游记
    ioi2021集训队作业
  • 原文地址:https://www.cnblogs.com/littleebeer/p/3365408.html
Copyright © 2011-2022 走看看