简体   繁体   English

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

[英]Passing a JSON object from visualwebgui to a htmlbox html page?

I have a situation where I am using Gizmox VWG 6.4 and a HTML page to surface some D3js visualisations. 我遇到的情况是,我正在使用Gizmox VWG 6.4和HTML页面来显示一些D3js可视化效果。

Currently I am generating the data with no problems. 目前,我正在毫无问题地生成数据。 The end result is that I have a JSON object in the correct format for my D3js app. 最终结果是我有一个D3js应用程序正确格式的JSON对象。 What I need to do is somehow host the HTML within Gizmox VWG (presumably via HtmlBox??), and then somehow make the JSON object available to the HtmlBox so the HTML/JS app can read that? 我需要做的是以某种方式在Gizmox VWG中托管HTML(大概通过HtmlBox ??),然后以某种方式使JSON对象可用于HtmlBox,以便HTML / JS应用程序可以读取它? Ideally without having to store the JSON on disk? 理想情况下,无需在磁盘上存储JSON?

Any ideas if this is even possible?? 有什么想法,甚至可能吗?

Thanks. 谢谢。

Sure this is possible using Visual WebGUi gateway to feed the HtmlBox. 确保可以使用Visual WebGUi网关来提供HtmlBox。 Say you have a Form with an HtmlBox, you can do the following: 假设您有一个带有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);
        }
    }

}

Gateways are in fact a really powerful feature of VWG. 网关实际上是VWG真正强大的功能。 See Here 这里

Hope this helps, Palli 希望这会有所帮助,Palli

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM