JNTemplate 模板标签传递url参数

浪淘沙4个月前后端70

一、模板

 private readonly SqlSugar.ISqlSugarClient _db;

 public Index1Model(SqlSugar.ISqlSugarClient db)
 {
     this._db = db;
 }
 public IActionResult OnGet()
 {
     string catid = Request.Query["catid"];
    var templateContent = "${TemplateValueHelper.PageTitle(catid)}";
    var template = Engine.CreateTemplate(templateContent);
    template.Set("TemplateValueHelper", new TemplateValueHelper(_db));
    template.Set("catid", catid);
    var result = template.Render();
    return Content(result);           
}

二、后端

 #region 获取当前分类的名字
 /// <summary>
 /// 获取当前分类的名字
 /// </summary>
 /// <param name="catid">分类名字</param>
 /// <returns></returns>
 public string PageTitle(string catid)
 {

     if (string.IsNullOrEmpty(catid))
     {
         return "";
     }
     return CommHelper.GuanLian("article_class", CommHelper.FilterSQL(catid), "dictname");
 }

 #endregion


相关文章

asp.net core 检测上传文件为图片格式

  #region 检测图片格式   var validMimeTypes = new[] { &...

asp.net core 取得页面form中所有表单值

public IActionResult OnPostSubmit()         { &n...

短信发送

@page @model xxtsoft.Web.Entry.Pages.Index1Model @{ } <form method="post"...

asp.net core webapi 调用furion 的webapi json接口

/// <summary> /// 根据学校读取支付科次 /// </summary> /// <returns>&l...

asp.net core postgresql 大数据高性能分页

 /// <summary> /// 分页:返回json格式,参数加密 /// </summary> /// <param nam...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。