JNTemplate 模板标签传递url参数

浪淘沙1年前后端256

一、模板

 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 razor 写入读取cookie集合

@{     Layout = null; } <form method="post">...

返回月份当天日期

  int daysInMonth = DateTime.DaysInMonth(_yf.Year, _yf.Month);...

asp.net core 图片左下角 加水印

using SixLabors.Fonts; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Drawi...

打包软件advanced installer使用

https://blog.csdn.net/m0_48667560/article/details/138671571...

asp.net core HttpClient post ,get

1、postusing System.Net.Http.Headers; using System.Text; using System.Text.Json;...

使用 Razor Pages 的多个 Handler

<form method="post" asp-page-handler="Save">    ...

发表评论    

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