コード例 #1
0
        protected void btnGenerateString_Click(object sender, EventArgs e)
        {
            string tempalte = "Templates/template.htm";//相对目录

            TestInfo info = new TestInfo();

            info.Title    = "测试标题";
            info.Content  = "测试内容,这是测试内容";
            info.Datetime = DateTime.Now;

            NVelocityHelper adapter = new NVelocityHelper(tempalte);

            adapter.AddKeyValue("title", "This is a title")
            .AddKeyValue("content", "This is a Content")
            .AddKeyValue("datetime", System.DateTime.Now)
            .AddKeyValue("TestInfo", info);

            this.txtCode.InnerHtml = adapter.ExecuteString();
        }