[英]Passing a JSON object from visualwebgui to a htmlbox html page?
我遇到的情况是,我正在使用Gizmox VWG 6.4和HTML页面来显示一些D3js可视化效果。
目前,我正在毫无问题地生成数据。 最终结果是我有一个D3js应用程序正确格式的JSON对象。 我需要做的是以某种方式在Gizmox VWG中托管HTML(大概通过HtmlBox ??),然后以某种方式使JSON对象可用于HtmlBox,以便HTML / JS应用程序可以读取它? 理想情况下,无需在磁盘上存储JSON?
有什么想法,甚至可能吗?
谢谢。
确保可以使用Visual WebGUi网关来提供HtmlBox。 假设您有一个带有HtmlBox的窗体,则可以执行以下操作:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Web;
using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Common.Gateways;
using Gizmox.WebGUI.Forms;
namespace VisualWebGuiApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
NameValueCollection NVC = new NameValueCollection();
NVC.Add("JsonParm1", "value1");
NVC.Add("JsonParm2", "value2");
this.htmlBox1.Url = (new GatewayReference(this, "generateJSON", NVC)).ToString();
}
protected override Gizmox.WebGUI.Common.Interfaces.IGatewayHandler ProcessGatewayRequest(Gizmox.WebGUI.Hosting.HostContext objHostContext, string strAction)
{
if (strAction == "generateJSON")
{
// make sure no caching takes place.
objHostContext.Response.Expires = -1;
objHostContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
objHostContext.Response.CacheControl = "no-cache";
objHostContext.Response.AddHeader("Pragma", "no-cache");
// Get the parameters from the gateway reference
string strParm1 = objHostContext.Request["JsonParm1"].ToString();
string strParm2 = objHostContext.Request["JsonParm2"].ToString();
// build your output and set content type
objHostContext.Response.ContentType = "text/html";
objHostContext.Response.Write("the data you want to write");
objHostContext.Response.Flush();
return null;
}
else
return base.ProcessGatewayRequest(objHostContext, strAction);
}
}
}
网关实际上是VWG真正强大的功能。 看这里
希望这会有所帮助,Palli
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.