}
}
public string GetModeUrl()
{
return ModeUrl;
}
public bool IsPCClient()
{
return BaseJsonMode.IsPCClient(ctx);
}
public bool isHTTPS()
{
return ctx.Request.IsSecureConnection;
}
public Hashtable OBJToHashTable(Object m_Parame)
{
/*
Hashtable m_HH = new Hashtable();
JsonHelper.OBJToHashTable(m_Parame, m_HH);
return m_HH;
*/
try
{
return JsonHelper.OBJToType<Hashtable>(m_Parame);
}
catch
{
return new Hashtable();
}
}
public List<Hashtable>OBJToListHashtable(Object m_Parame)
{
return JsonHelper.OBJToType<List<Hashtable>>(m_Parame);
}
public Hashtable JsonToHashtable(string jsonString)
{
/*
Hashtable m_HH = new Hashtable();
JsonHelper.JsonToHashtable(jsonString, m_HH);
return m_HH;
*/
return JsonHelper.JsonStrToOBJ<Hashtable>(jsonString);
}
}
使用JNTemplate的页面例子
页面函数:
static public ReturnJson uniAppTestPage(HttpContext ctx, Object m_Parame)
{
Hashtable m_HH = new Hashtable();
JsonHelper.OBJToHashTable(m_Parame, m_HH);
ReturnJson m_ReturnJson = new ReturnJson();
try
{
string type = "";
if (KeyIsOK(m_HH, "type"))
【ASP.NET原创框架十-应用模块开发之页面生成】{
type = m_HH["type"].ToString();
}
m_ReturnJson.bOK = true;
oneData m_oneData = https://www.isolves.com/it/cxkf/yy/net/2022-11-21/new oneData();
m_oneData.m_HH = new Hashtable();
m_oneData.A = "1";
m_oneData.B = 2;
m_oneData.m_HH["A"] = type;
m_oneData.m_oneData = https://www.isolves.com/it/cxkf/yy/net/2022-11-21/new oneData();
m_oneData.m_oneData.m_HH = new Hashtable();
m_oneData.m_oneData.A = "11";
m_oneData.m_oneData.B = 22;
m_oneData.m_oneData.m_HH["A"] = "下级测试数据";
oneData m_oneData0 = new oneData();
m_oneData0.A = "c1";
m_oneData.m_HH["m_oneData"] = m_oneData0;//错误Hashtable内只能包含基本数据类型如int string float double 不能包含对象否则模板访问失败
int i;
List<Hashtable> m_HHList = new List<Hashtable>();
for (i = 0; i < 10; i++)
{
Hashtable m_oneHH = new Hashtable();
m_oneHH["pos"] = i;
m_HHList.Add(m_oneHH);
}
m_oneData.m_oneData.m_HHList = m_HHList;
List<oneRow> m_RowArray = new List<oneRow>();
for (i = 0; i < 10; i++)
{
oneRow m_oneRow = new oneRow();
m_oneRow.pos = i;
m_RowArray.Add(m_oneRow);
}
m_oneData.m_oneData.m_HH["array"] = m_RowArray.ToArray();
m_oneData.m_oneData.m_HH["array2"] = m_HHList;
m_oneData.m_oneData.m_RowArray = m_RowArray;
m_ReturnJson.m_ReturnOBJ = RenderPageView(ctx, m_JsonModePath, "uniappTestPage.shtml", m_oneData,typeof(menuClass));
}
catch
{
m_ReturnJson.bOK = false;
m_ReturnJson.sMsg = "渲染uniappTestPage失败";
}
return m_ReturnJson;
}
uniappTestPage.shtml的页面内容纯测试模板语法所以里面未出现html标签
m_oneData.A:${model.A},m_oneData.B:${model.B},m_oneData.m_HH["A"]:${model.m_HH["A"]},m_oneData.m_oneData.A:${model.m_oneData.A},m_oneData.m_oneData.B:${model.m_oneData.B},m_oneData.m_oneData.m_HH["A"]:${model.m_oneData.m_HH["A"]},m_SessionLink.username:${engine.GetSessionLink().username}
权限判断:CoreSYS.SYS/AddCompany:${if(engine.HavePower("CoreSYS.SYS","AddCompany"))}有权限执行${else}无权限执行${end}
对象列表数据:${foreach(one in
model.m_oneData.m_RowArray)}序号-${one.pos} ${end}<br />
Hashtable的List列表数据:${foreach(one in model.m_oneData.m_HHList)}序号-${one["pos"]} ${end}</br>
Hashtable中对象${model.m_HH["m_oneData"]}</br>
引号内</br>
Hashtable的List列表数据:"${foreach(one in model.m_oneData.m_HHList)}序号-${one["pos"]} ${end}"</br>
模板页内变量使用<br />
${set(a=123)}<br />
输出:${a}
<br />
<ul>
定义ii变量
${set(ii=0)}
${for(ii=1;ii<4;ii++)}
<li>${ii}</li>
${end}
</ul>
</br>
复杂语法测试<br />
${set(m_SessionLink=engine.GetSessionLink())}
${if(model.m_oneData.m_HH.ContainsKey("BB"))}
有BB
${else}
无BB
${end}
<br />
复杂测试
推荐阅读
- HTTP 框架 Hertz 实践入门:性能测试指南
- 原创|喜迎世界杯,众星分享手指舞,鹿晗拿到解说世界杯的资格
- 祝福生日的短信原创
- 高压电线下打手机可能被电击吗?
- 原创 安徽有一座历史文化名山 安徽被称为天下第一名山
- 对于 Display 框架,我需要了解 KMS api 吗?| Linux 驱动
- 装了.Net 7.0后,工程框架用 net6 的 dotnet watch 出错临时解决方案
- python爬虫之Scrapy框架,基本介绍使用以及用框架下载图片案例
- ASP.NET中如何通过QueryString进行页面传值
- 原创唯美现代诗歌! 自创最唯美的现代诗歌!