[英]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.