JNTemplate 模板标签传递url参数

浪淘沙12个月前后端193

一、模板

 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 SqlSugar 多库切换

  private readonly SqlSugar.ISqlSugarClient _db;     ...

asp.net core razor 中文搜索 url转码

 return Redirect("feedback_list?fst=" + fst + "&Status=" + Status + &qu...

asp.net core razor 获取当前url

 @Request.Scheme://@Request.Host/anysc/dd_ts_stu...

JNTemplate 模板标签读取dt数据

一、模板标签using JinianNet.JNTemplate; private readonly SqlSugar.ISqlSugarClient _db;...

普能html页面post到 cshtml页面,出现400错误解决方法

  [IgnoreAntiforgeryToken]  public class keywordsModel : PageModel  {    &n...

发表评论    

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