将JSON对象从visualwebgui传递到htmlbox html页面?

将JSON对象从visualwebgui传递到htmlbox html页面?,json,d3.js,visual-web-gui,Json,D3.js,Visual Web Gui,我使用Gizmox VWG 6.4和HTML页面呈现一些D3js可视化 目前我生成的数据没有问题。最终的结果是,我的D3js应用程序有一个格式正确的JSON对象。我需要做的是以某种方式在Gizmox VWG中托管HTML(可能是通过HtmlBox???),然后以某种方式使JSON对象可用于HtmlBox,以便HTML/JS应用程序可以读取它?理想情况下不必将JSON存储在磁盘上 如果这是可能的话,有什么想法吗 谢谢 确保可以使用VisualWebGUI网关向HtmlBox提供信息。假设您有一个带

我使用Gizmox VWG 6.4和HTML页面呈现一些D3js可视化

目前我生成的数据没有问题。最终的结果是,我的D3js应用程序有一个格式正确的JSON对象。我需要做的是以某种方式在Gizmox VWG中托管HTML(可能是通过HtmlBox???),然后以某种方式使JSON对象可用于HtmlBox,以便HTML/JS应用程序可以读取它?理想情况下不必将JSON存储在磁盘上

如果这是可能的话,有什么想法吗


谢谢

确保可以使用VisualWebGUI网关向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);
        }
    }

}
事实上,网关是大众汽车一个非常强大的功能。看

希望这有帮助,
帕利

嘿,谢谢帕利,这看起来是个不错的选择!对大众汽车更高级的部分来说还是有点新鲜,不过我在不久前“黑客”了一个网关选项,可以自动下载csv文件。。只是没有为这种类型的请求建立连接。事实上,我的“糟糕”解决方案是:this.htmlBox1.InvokeClientMethod(“tfrJSON”,JSONdata);它将JSON数据传递给一个名为tfrJSON的JS函数——在我的例子中,这并不坏,因为JSON非常小。不过,我们一定会尝试一下您的解决方案!!再次感谢。